Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9250093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:21:55+00:00 2026-06-18T10:21:55+00:00

I am making a Qt application and want to intercept keypresses at a deeper

  • 0

I am making a Qt application and want to intercept keypresses at a deeper level. To do this I overrided the QWidget::macEvent() function to intercept the EventRef parameter.

For different events (i.e. keyboard events, mouse events, window events) EventRef is equal to the following values:

0×104d649f0
0×101425740
0×104d649f0
0×101485950
0×101425740
0×101485950

How can I tell if the event is a keyboard event? And how can I find out which key was pressed? I’ve looked at event handling documentation and most of them don’t mention EventRef. Some articles mention how EventRef is the Carbon event derived from the Cocoa NSEvent event.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T10:21:56+00:00Added an answer on June 18, 2026 at 10:21 am

    After some guessing work, and looking at this chapter from a book, I’ve succeeded in interpreting the EventRef object for keypresses in Qt applications:

    MyProject.pro: Include Carbon framework:

    macx {
        LIBS += -framework Carbon
    }
    

    MyWidget.h: override QWidget::macEvent()

    class MyWidget : public QWidget {
    
        ...
    
        private:
            #if defined(Q_OS_MAC)
                bool macEvent(EventHandlerCallRef, EventRef event);
            #endif
    };
    

    MyWidget.cpp:

    #if defined(Q_OS_MAC)
        #include <Carbon/Carbon.h>
    #endif
    
    ...
    
    #if defined(Q_OS_MAC)
        bool MyWidget::macEvent(EventHandlerCallRef, EventRef event) {
            uint32_t keyCode;
    
            switch (GetEventClass(event)) {
                case kEventClassApplication:
                    qDebug() << "kEventClassApplication";
                    break;
                case kEventClassCommand:
                    qDebug() << "kEventClassCommand";
                    break;
                case kEventClassControl:
                    qDebug() << "kEventClassControl";
                    break;
                case kEventClassKeyboard:
                    qDebug() << "kEventClassKeyboard";
    
                    switch(GetEventKind(event)) {
                        case kEventRawKeyDown:
                            qDebug() << "kEventRawKeyDown";
    
                            GetEventParameter(event, kEventParamKeyCode, typeUInt32, NULL, sizeof(keyCode), NULL, &keyCode);
                            qDebug() << "keyCode =" << keyCode;
    
                            break;
                        case kEventRawKeyRepeat:
                            qDebug() << "kEventRawKeyRepeat";
                            break;
                        case kEventRawKeyUp:
                            qDebug() << "kEventRawKeyUp";
    
                            GetEventParameter(event, kEventParamKeyCode, typeUInt32, NULL, sizeof(keyCode), NULL, &keyCode);
                            qDebug() << "keyCode =" << keyCode;
    
                            break;
                        case kEventRawKeyModifiersChanged:
                            qDebug() << "kEventRawKeyModifiersChanged";
                            break;
                        case kEventHotKeyPressed:
                            qDebug() << "kEventHotKeyPressed";
                            break;
                        case kEventHotKeyReleased:
                            qDebug() << "kEventHotKeyReleased";
                            break;
                    }
    
                    break;
                case kEventClassMenu:
                    qDebug() << "kEventClassMenu";
                    break;
                case kEventClassMouse:
                    qDebug() << "kEventClassMouse";
                    break;
                case kEventClassTablet:
                    qDebug() << "kEventClassTablet";
                    break;
                case kEventClassTextInput:
                    qDebug() << "kEventClassTextInput";
                    break;
                case kEventClassWindow:
                    qDebug() << "kEventClassWindow";
                    break;
                default:
                    break;
            }
    
            return true;
        }
    #endif
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For an application I'm making I want to intercept window messages from an external
I am making an application in silverlight 3.0 In that application i want to
I making an application with my own keyboard and I want to completely DISABLE
I am making an application that I dont want it to close. So on
I am making an application in Java and I want to allow users to
I'm making an application using Quickly, and I want to add a Webkit widget
I'm making chat application and read messages data from SQLite database. I want to
Hi I want to try making a simple application for android phones for which
I am making a command-line c++ application and I want text to be on
----EDIT---- I am making an jquery mobile application. Now I want to check which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.