event-filters are used like that
{
if (ob
==someWidget
& e
->type
() == QEvent::KeyPress) { printf("is it coming inside event..\n");
const QKeyEvent *ke
= static_cast<QKeyEvent
*>
(e
);
if(ke->key()==Qt::Key_F1) {
printf("F1 buttin clicked..\n");
}
return true;
}
return QWidget::eventFilter(ob, e
);
}
event-filters are used like that
bool DDView:: eventFilter(QObject *ob, QEvent *e)
{
if (ob==someWidget & e->type() == QEvent::KeyPress) {
printf("is it coming inside event..\n");
const QKeyEvent *ke = static_cast<QKeyEvent *>(e);
if(ke->key()==Qt::Key_F1) {
printf("F1 buttin clicked..\n");
}
return true;
}
return QWidget::eventFilter(ob, e);
}
To copy to clipboard, switch view to plain text mode
where someWidget would be the widget whose events you want to intercept.
You need to install the event-filter on that widget, first:
someWidget->installEventFilter(this);
someWidget->installEventFilter(this);
To copy to clipboard, switch view to plain text mode
Note that QEvent::NonClientAreaMouseButtonPress are mousevents outside of any QWidget (iiuc) and can not be intercepted with an event filter.
Are the mouse events you are interested in inside your window or just somewhere on the desktop? In the latter case you can use grabMouse().
Bookmarks