当前位置: 首页>>代码示例>>C++>>正文


C++ QWidget::installEventFilter方法代码示例

本文整理汇总了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
    {
开发者ID:crayonink,项目名称:calligra-2,代码行数:30,代码来源:kocursor.cpp

示例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();
}
开发者ID:GabLeRoux,项目名称:CopyQ,代码行数:27,代码来源:itemdelegate.cpp

示例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);
}
开发者ID:anchowee,项目名称:QtCreator,代码行数:26,代码来源:historycompleter.cpp

示例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;
};
开发者ID:someone972,项目名称:driver-level-editor,代码行数:7,代码来源:EventFilters.cpp

示例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);
}
开发者ID:,项目名称:,代码行数:26,代码来源:

示例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));
}
开发者ID:a-dilla,项目名称:Valentina,代码行数:33,代码来源:vpropertyformwidget.cpp

示例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;
}
开发者ID:colinw7,项目名称:CQPropertyTree,代码行数:36,代码来源:CQPropertyDelegate.cpp

示例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()));
}
开发者ID:Rapotkinnik,项目名称:AppSkeleton,代码行数:34,代码来源:MainWindow.cpp

示例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);
}
开发者ID:Camelek,项目名称:qtmoko,代码行数:35,代码来源:monthview.cpp

示例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();
}
开发者ID:,项目名称:,代码行数:25,代码来源:

示例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
}
开发者ID:,项目名称:,代码行数:34,代码来源:

示例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 );
    }
}
开发者ID:kthxbyte,项目名称:Qt1.45-Linaro,代码行数:30,代码来源:qwhatsthis.cpp

示例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);
        }
}
开发者ID:roandbox,项目名称:raindrop,代码行数:10,代码来源:toolbar.cpp

示例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);
     }
 }
开发者ID:2gis,项目名称:2gisqt5android,代码行数:11,代码来源:qdatawidgetmapper.cpp

示例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);
     }
 }
开发者ID:3163504123,项目名称:phantomjs,代码行数:11,代码来源:qdatawidgetmapper.cpp


注:本文中的QWidget::installEventFilter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。