本文整理汇总了C++中QWidget::installEventFilter方法的典型用法代码示例。如果您正苦于以下问题:C++ QWidget::installEventFilter方法的具体用法?C++ QWidget::installEventFilter怎么用?C++ QWidget::installEventFilter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWidget
的用法示例。
在下文中一共展示了QWidget::installEventFilter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setAutoHideCursor
void KoCursorPrivate::setAutoHideCursor( QWidget *w, bool enable, bool customEventFilter )
{
if ( !w || !enabled )
return;
QWidget* viewport = 0;
QAbstractScrollArea * sv = qobject_cast<QAbstractScrollArea *>( w );
if ( sv )
viewport = sv->viewport();
if ( enable )
{
if ( m_eventFilters.contains( w ) )
return;
KoCursorPrivateAutoHideEventFilter* filter = new KoCursorPrivateAutoHideEventFilter( w );
m_eventFilters.insert( w, filter );
if (viewport) {
m_eventFilters.insert( viewport, filter );
connect(viewport, SIGNAL(destroyed(QObject*)), this, SLOT(slotViewportDestroyed(QObject*)));
}
if ( !customEventFilter ) {
w->installEventFilter( filter ); // for key events
if (viewport)
viewport->installEventFilter( filter ); // for mouse events
}
connect( w, SIGNAL(destroyed(QObject*)),
this, SLOT(slotWidgetDestroyed(QObject*)) );
}
else
{
示例2: setIndexWidget
void ItemDelegate::setIndexWidget(const QModelIndex &index, ItemWidget *w)
{
reset(&m_cache[index.row()], w);
if (w == NULL)
return;
QWidget *ww = w->widget();
if (!m_antialiasing) {
QFont f = ww->font();
f.setStyleStrategy(QFont::NoAntialias);
ww->setFont(f);
foreach (QWidget *child, ww->findChildren<QWidget *>("item_child"))
child->setFont(f);
}
// Try to get proper size by showing item momentarily.
ww->show();
w->updateSize(m_maxSize, m_idealWidth);
ww->hide();
ww->installEventFilter(this);
w->setCurrent(m_view->currentIndex() == index);
emit rowSizeChanged();
}
示例3: QCompleter
HistoryCompleter::HistoryCompleter(QObject *parent)
: QCompleter(parent)
, d_ptr(new HistoryCompleterPrivate(this))
{
// make an assumption to allow pressing of the down
// key, before the first model run:
// parent is likely the lineedit
QWidget *p = qobject_cast<QWidget *>(parent);
if (p) {
p->installEventFilter(d_ptr->model);
QString objectName = p->objectName();
if (objectName.isEmpty())
return;
d_ptr->model->list = d_ptr->model->settings->value(objectName).toStringList();
}
QLineEdit *l = qobject_cast<QLineEdit *>(parent);
if (l && d_ptr->model->list.count())
l->setText(d_ptr->model->list.at(0));
setModel(d_ptr->model);
HistoryLineDelegate *delegate = new HistoryLineDelegate;
HistoryLineView *view = new HistoryLineView(d_ptr, delegate->pixmap.width());
setPopup(view);
view->setItemDelegate(delegate);
}
示例4:
QWidget * EventFilterDelegate::createEditor ( QWidget * parent, const QStyleOptionViewItem & option, const QModelIndex & index ) const
{
QWidget* out = QItemDelegate::createEditor(parent,option,index);
if(filter)
out->installEventFilter(filter);
return out;
};
示例5: updateWindow
void QWSEmbedWidgetPrivate::updateWindow()
{
Q_Q(QWSEmbedWidget);
QWidget *win = q->window();
if (win == window)
return;
if (window) {
window->removeEventFilter(q);
QWSEmbedCommand command;
command.setData(windowId, embeddedId, QWSEmbedEvent::StopEmbed);
QWSDisplay::instance()->d->sendCommand(command);
}
window = win;
if (!window)
return;
windowId = window->winId();
QWSEmbedCommand command;
command.setData(windowId, embeddedId, QWSEmbedEvent::StartEmbed);
QWSDisplay::instance()->d->sendCommand(command);
window->installEventFilter(q);
q->installEventFilter(q);
}
示例6: buildEditor
void VPropertyFormWidget::buildEditor(VProperty* property, QFormLayout* formLayout, Property type)
{
// Add property (no child properties)
// Create the editor (if it doesn't work, create empty widget)
QWidget* tmpEditor = property->createEditor(this, QStyleOptionViewItem(), nullptr);
if (!tmpEditor)
{
tmpEditor = new QWidget(this);
}
// set tooltip and whats this
tmpEditor->setToolTip(property->getDescription());
tmpEditor->setWhatsThis(property->getDescription());
// Install event filter
tmpEditor->installEventFilter(this);
// Set the editor data
property->setEditorData(tmpEditor);
// add new row
if (type == Property::Complex)
{
QString name = "<b>"+property->getName()+"</b>";
formLayout->addRow(name, tmpEditor);
}
else
{
formLayout->addRow(property->getName(), tmpEditor);
}
d_ptr->EditorWidgets.append(VPropertyFormWidgetPrivate::SEditorWidget(tmpEditor));
}
示例7: getModelItem
/*! create editor for tree widget item
*/
QWidget *
CQPropertyDelegate::
createEditor(QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &index) const
{
QTreeWidgetItem *item = getModelItem(index);
assert(item);
CQPropertyDelegate *th = const_cast<CQPropertyDelegate *>(this);
QWidget *w = 0;
if (CQPropertyItem::isType(item->type())) {
CQPropertyItem *item1 = dynamic_cast<CQPropertyItem *>(item);
assert(item1);
if (index.column() == 1)
w = item1->createEditor(parent);
}
else
assert(false);
if (w) {
w->updateGeometry();
if (w->layout())
w->layout()->invalidate();
//w->setFixedSize(sizeHint(option, index));
w->installEventFilter(th);
}
return w;
}
示例8: QMainWindow
MainWindow::MainWindow(QWidget *parent): QMainWindow(parent),
_positionShift(QPoint(0,0)),
_toolBar(new QToolBar(this)),
_iconLable(new QLabel(this))
{
setObjectName("MainWindow");
setWindowFlags(Qt::FramelessWindowHint);
setContextMenuPolicy(Qt::NoContextMenu);
setMouseTracking(true);
QMainWindow::addToolBar(Qt::TopToolBarArea, _toolBar);
_toolBar->setObjectName("MenuToolBar");
_toolBar->setMovable(false);
_toolBar->setContextMenuPolicy(Qt::NoContextMenu);
QWidget *spacerWidget = new QWidget(_toolBar);
spacerWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
_toolBar->addWidget(_iconLable);
_spacerAction = _toolBar->addWidget(spacerWidget);
_toolBar->installEventFilter(this);
spacerWidget->installEventFilter(this);
//TODO: Зафигачить механизм загрузки всего стиля от css до иконок основных кнопочек (крестик закрытия)
QAction *closeAction = _toolBar->addAction(QIcon(":/icons/cross_grey.png"), QString::null);
// setIcon(QIcon(":/icons/cross_grey.png"));
loadStyleSheet(":/css/dark_theme.css");
resize(700, 500);
connect(closeAction, SIGNAL(triggered()), this, SLOT(close()));
}
示例9: QCalendarWidget
MonthView::MonthView(QWidget *parent, const QCategoryFilter& c, QSet<QPimSource> set)
: QCalendarWidget(parent)
{
setObjectName("monthview");
setVerticalHeaderFormat(NoVerticalHeader);
setFirstDayOfWeek( Qtopia::weekStartsOnMonday() ? Qt::Monday : Qt::Sunday );
QDate start = QDate::currentDate();
start.setYMD(start.year(), start.month(), 1);
QDate end = start.addDays(start.daysInMonth() - 1);
model = new QOccurrenceModel(QDateTime(start, QTime(0, 0, 0)), QDateTime(end.addDays(1), QTime(0, 0)), this);
if (set.count() > 0)
model->setVisibleSources(set);
model->setCategoryFilter(c);
connect(model, SIGNAL(modelReset()), this, SLOT(resetFormatsSoon()));
connect(this, SIGNAL(currentPageChanged(int,int)), this, SLOT(updateModelRange(int,int)));
// Since we don't know if we'll get a model reset from the model
// at startup, force a timer
dirtyTimer = new QTimer();
dirtyTimer->setSingleShot(true);
dirtyTimer->setInterval(0);
connect(dirtyTimer, SIGNAL(timeout()), this, SLOT(resetFormats()));
resetFormatsSoon();
// XXX find the QCalendarView class so we can handle Key_Back properly :/
// [this comes from qtopiaapplication.cpp]
QWidget *table = findChild<QWidget*>("qt_calendar_calendarview");
if (table)
table->installEventFilter(this);
}
示例10: transparentChanged
void TransparentTop::transparentChanged()
{
#ifdef WIN32
if (bCanTransparent){
QWidget *p = static_cast<QWidget*>(parent());
if (*useTransparent){
if (!m_bUseTransparent){
SetWindowLongW(p->winId(), GWL_EXSTYLE, GetWindowLongW(p->winId(), GWL_EXSTYLE) | WS_EX_LAYERED);
SetLayeredWindowAttributes(p->winId(), p->colorGroup().background().rgb(), 255, LWA_ALPHA);
if (p->isVisible())
RedrawWindow(p->winId(), NULL, NULL, RDW_UPDATENOW);
p->installEventFilter(this);
m_bUseTransparent = true;
}
}else{
if (m_bUseTransparent){
SetWindowLongW(p->winId(), GWL_EXSTYLE, GetWindowLongW(p->winId(), GWL_EXSTYLE) & ~WS_EX_LAYERED);
p->removeEventFilter(this);
m_bUseTransparent = false;
}
}
}
#endif
setTransparent();
}
示例11: setState
void TransparentPlugin::setState()
{
QWidget *main = getMainWindow();
if (main == NULL)
return;
#ifdef WIN32
if (timer == NULL){
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(tick()));
main->installEventFilter(this);
SetWindowLongW(main->winId(), GWL_EXSTYLE, GetWindowLongW(main->winId(), GWL_EXSTYLE) | WS_EX_LAYERED);
SetLayeredWindowAttributes(main->winId(), main->colorGroup().background().rgb(), 0, LWA_ALPHA);
RedrawWindow(main->winId(), NULL, NULL, RDW_UPDATENOW);
main->setMouseTracking(true);
m_bActive = main->isActiveWindow();
m_bState = !m_bActive;
}
bool bNewState = m_bActive || m_bHaveMouse;
if (bNewState == m_bState){
BYTE d = (BYTE)(bNewState ? 255 : QMIN((100 - getTransparency()) * 256 / 100, 255));
SetLayeredWindowAttributes(main->winId(), main->colorGroup().background().rgb(), d, LWA_ALPHA);
return;
}
m_bState = bNewState;
startTime = GetTickCount();
timer->start(10);
#else
if (!top) {
top = new TransparentTop(main, getTransparency());
connect(top,SIGNAL(destroyed()),this,SLOT(topDestroyed()));
}
top->setTransparent(getTransparency());
#endif
}
示例12: add
void QWhatsThis::add( QWidget * widget, const QPixmap & icon,
const char * title, const char * text,
bool deepCopy )
{
QWhatsThisPrivate::setUpWhatsThis();
QWhatsThisPrivate::Item * i = wt->dict->find( (void *)widget );
if ( i )
remove( widget );
i = new QWhatsThisPrivate::Item;
i->dc = deepCopy;
if ( deepCopy ) {
i->s = new char[ qstrlen(text) + 1 ];
qstrcpy( i->s, text );
if ( title ) {
i->t = new char[ qstrlen(text) + 1 ];
qstrcpy( i->t, text );
}
} else {
i->s = (char*)text;
i->t = (char*)title;
}
i->pm = icon;
wt->dict->insert( (void *)widget, i );
QWidget * tlw = widget->topLevelWidget();
if ( !wt->tlw->find( (void *)tlw ) ) {
wt->tlw->insert( (void *)tlw, tlw );
tlw->installEventFilter( wt );
}
}
示例13: actionEvent
void ToolBar::actionEvent(QActionEvent *event)
{
QToolBar::actionEvent(event);
if (event->type() == QEvent::ActionAdded)
if (event->action()) {
QWidget *widget = widgetForAction(event->action());
if (widget)
widget->installEventFilter(this);
}
}
示例14: flipEventFilters
inline void flipEventFilters(QAbstractItemDelegate *oldDelegate,
QAbstractItemDelegate *newDelegate)
{
for (QList<WidgetMapper>::const_iterator it = widgetMap.cbegin(), end = widgetMap.cend(); it != end; ++it) {
QWidget *w = it->widget;
if (!w)
continue;
w->removeEventFilter(oldDelegate);
w->installEventFilter(newDelegate);
}
}
示例15: flipEventFilters
inline void flipEventFilters(QAbstractItemDelegate *oldDelegate,
QAbstractItemDelegate *newDelegate)
{
for (int i = 0; i < widgetMap.count(); ++i) {
QWidget *w = widgetMap.at(i).widget;
if (!w)
continue;
w->removeEventFilter(oldDelegate);
w->installEventFilter(newDelegate);
}
}