Currently, I am trying to pass system X11 events (on Linux) to an object I have created. To do this, I have installed an eventFilter onto my object from my QApplication. This works, in that it gets all of the events of the application. However I need to pass the object X11 events as well.
I went ahead and created a x11Event in my object, hoping that it would receive events from X11, but this does not appear to be the case.
Is there anyway to pass X11 events directly to my object, inside of my application?
You can receive
XEvents through:QAbstractEventDispatcher::instance()->setEventFilter()which will receive allXEvents.qApp->setEventFilter()which will only receive events targeted at the application.QApplication::x11EventFilterQWidget::x11Eventfor your top level window(s) (child widgets don’t receiveXEvents).in that order. If any of these functions returns
truefor any event, the next function won’t receive that event.Some events can also be filtered by Qt between these functions, for example
QWidget::x11Eventdoesn’t receiveXKeyEvents (which are filtered by theQInputContext::x11FilterEventfunction of the widget which has keyboard focus).For more details, you should look at Qt sources: QEventDispatcher_x11.cpp and the function
QApplication::x11ProcessEventin QApplication_x11.cppSo for the most part, if you reimplement only the
x11Eventfunction in yourQDialogderived class, you should already receive mostXEvent. And if you want your child widgets to receive them too, you could call manually theirx11Eventfunctions from your reimplementation ofQDialog::x11Event.