Results 1 to 2 of 2

Thread: subclassing QEvent to create custom events example

  1. #1
    Join Date
    Jul 2012
    Posts
    10
    Thanks
    5
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11

    Default subclassing QEvent to create custom events example

    I had a Qt3 app that used QEvents setData method and I am porting this to Qt4. I noticed there is not setData function anymore.

    I read in the docs that you should subclass QEvent.

    Does anyone have an example of how to subclass QEvent to make custom events and how to set the data for that custom event?

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: subclassing QEvent to create custom events example

    Just create a derived class like you would for any other C++ class.

    Pass an event number as the type to the base class constructor, e.g. starting at QEvent::User + 1 or using QEvent::registerEventType() to generate one.

    Since this is your class now, you can put any number of data members into it that you'd like.

    Cheers,
    _

Similar Threads

  1. send QEvent::NonClientAreaMouse* events
    By R-Type in forum Qt Programming
    Replies: 0
    Last Post: 31st October 2012, 11:22
  2. Create Custom build specification for Qt 4.7 for my custom SDK
    By danics in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 19th October 2010, 15:23
  3. Using custom events.
    By hickscorp in forum Qt Programming
    Replies: 16
    Last Post: 17th June 2010, 19:30
  4. Pass custom events to another process
    By TTGator in forum Qt Programming
    Replies: 9
    Last Post: 14th January 2009, 22:02
  5. custom events
    By momesana in forum Qt Programming
    Replies: 5
    Last Post: 30th January 2008, 23:20

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.