Nominate our 2022 Qt Champions!

Which header/framework to add to get EventRef type for QT 5.3

  • Current we are including Carbon.h to get access to the EventRef type so that we can convert it to NSEvents as shown below

    @#include "Carbon/Carbon.h"

    nativeEvent(const QByteArray& eventType, void* message,long* result)
    EventRef event = reinterpret_cast<EventRef>(message);
    NSAutoreleasePool *poolP = [[NSAutoreleasePool alloc] init];
    NSEvent *eventP = [NSEvent eventWithEventRef: event];

    Is the above code doing correct conversions for EventRef, also is it the right thing to do to include Carbon.h header for the same ?

  • Lifetime Qt Champion


    Qt 5 implements only Cocoa, so you can cast directly to NSEvent

  • The doc says:
    "On Mac, eventType is set to "mac_generic_NSEvent", and the message can be casted to an EventRef."
    so the header is
    #include <Carbon/Carbon.h>

  • This is the include needed:
    #include <AppKit/NSEvent.h>

Log in to reply