error: ‘xcb_generic_event_t’ was not declared in this scope

代码:

bool tray::nativeEventFilter(const QByteArray &eventType, void *message, long *)
{
    qDebug("tray::nativeEventFilter:%s\n", eventType.data());
    if (eventType == "xcb_generic_event_t") {
        xcb_generic_event_t* ev = static_cast<xcb_generic_event_t *>(message);
        // ...
    }
    return false;
}

问题标签页:/home/test/Downloads/tray/tray/tray.cpp:244: error: unknown type name 'xcb_generic_event_t'

输出窗口:

../tray/tray.cpp:244:9: error: ‘xcb_generic_event_t’ was not declared in this scope
         xcb_generic_event_t* ev = static_cast<xcb_generic_event_t *>(message);
         ^~~~~~~~~~~~~~~~~~~
../tray/tray.cpp:244:9: note: suggested alternative: ‘xGenericEvent’
         xcb_generic_event_t* ev = static_cast<xcb_generic_event_t *>(message);
         ^~~~~~~~~~~~~~~~~~~
         xGenericEvent

解决:#include <xcb/xcb.h>

上一篇:qt.qpa.plugin: Could not load the Qt platform plugin “xcb“ in ““ even though it was found. This appl


下一篇:Qt报错:qt.qpa.xcb: QXcbConnection: XCB error: 8 (BadMatch).....