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 8611205
In Process

The Archive Base Latest Questions

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

I am experimenting with custom events in Qt Creator. I am currently examining this

  • 0

I am experimenting with custom events in Qt Creator. I am currently examining this example code on another site:

bool MyClass::event(QEvent* e)
{
    if (e && e->type() == MyCustomEventType) {
       MyCustomEvent* ce = dynamic_cast<MyCustomEventType*>(e);
       return handleCustomEvent(ce);
    }
    // very important: still handle all the other Qt events!
    return QObject::event(e);
}

The conditional statement checks if the event passed is the custom event, then it executes code that it wants to happen when the event occurs. What I do not understand is return handleCustomEvent(e) (what is this function supposed to do and where is it supposed to be declared?) and what return QObject::event(e) does. From what I read on the Qt documentation, the only thing this function does is return whether the event’s function (is this handleCustomEvent?) is “recognized and processed”. Is this supposed to handle all other events in the loop?

  • 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-12T04:18:57+00:00Added an answer on June 12, 2026 at 4:18 am

    handleCustomEvent() is the method you need to implement in your class MyClass which will process your Custom Event MyCustomEventType.

    If it’s not your custom event, the last line return QObject::event(e); will be called to handle other events type.

    So the method in your snippet bool MyClass::event(QEvent* e), is acting like a routing code, to decide where to send the event for processing, and does not actually process the events.

    Once decided that 'e' is of type MyCustomEventType – it invokes handleCustomEvent() which will contain your code to handle this event type.
    If not – the last line calls QObject::event() to process it instead. This will handle all other remaining types of events.
    So, no, you need not worry about handling other events, unless you want to.


    So, you’d declare the handleCustomEvent() in MyClass and implement it as well.
    Something like:

    class MyClass {
           ...
           ...
          public:
             bool handleCustomEvent(MyCustomEventType* e);
           ...
           ...
    };
    

    In the implementation you may have the logic as you require – to actually do the processing for your custom-event type MyCustomEventType.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently experimenting with custom (level 2 DOM) events and I've now arrived at
I'm currently experimenting with some RESTful JAX and I want to validate a custom
I'm experimenting with writing my own custom MembershipProvider in asp.net and I want to
I have been experimenting with Custom Actions in order to encrypt part of the
I am experimenting with derived custom controls, and I created what I thought would
I am experimenting with zurb foundations responsive design framework with my own custom media
I'm experimenting with a custom LayoutManager and I don't understand the subtleties of using
i'm experimenting with seam interceptors. I i have a custom annotation defined as: @Target(TYPE)
I'm experimenting around with writing custom WinForms components and I wrote a couple of
I've recently started experimenting with DataBinding and implementing DependencyProperties for my custom classes. It

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.