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?
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,
_