Can not catch XCB_VISIBILITY_NOTIFY event in Qt6
-
I'm able to receive event XCB_VISIBILITY_NOTIFY in Qt5 with NativeEvent and xcb connection:
xcb_connection_t *c= QX11Info::connection(); const uint32_t eventMask = 0x1FBFFFF;//XCB_EVENT_MASK_VISIBILITY_CHANGE|XCB_EVENT_MASK_EXPOSURE; xcb_change_window_attributes(c,findSubset->winId(),XCB_CW_EVENT_MASK, &eventMask);
but in Qt6, i can not make it work: QX11Info is not there any more and I tried:
xcb_connect(nullptr, nullptr);
QGuiApplication::platformNativeInterface()->nativeResourceForIntegration("connection");
none works.
-
In Qt6, the QX11Info class has been removed, and the XCB event handling approach has shifted to rely on QAbstractNativeEventFilter and native interfaces provided by QGuiApplication.
Try to check your issue out in grok or deepseek.
Use something like:auto *x11App = QGuiApplication::nativeInterface<QNativeInterface::QX11Application>(); if (!x11App) { qWarning() << "Failed to get QX11Application interface"; return -1; } xcb_connection_t *connection = x11App->connection(); if (!connection) { qWarning() << "Failed to get XCB connection"; return -1; }
-
ok, thanks, your solutions work and I'm able to get the xcb connection.
And I'm able to use xcb_change_window_attributes() (with above code using XCB_CW_EVENT_MASK) to turn on/off receiving native events for a Window (for example XCB_FOCUS_IN), but except the XCB_VISIBILITY_NOTIFY event. I just can not receive this event. is it related to something changed in Qt6?