[SOLVED] How do you create a new event?
-
I would know like to do a new event to use QEvent::user
In particular, how do you do an event, when you change a variable?
-
@Jose-Antonio said:
I would know like to do a new event to use QEvent::user
In particular, how do you do an event, when you change a variable?
Hi, and welcome to the Qt Dev Net!
For detecting change of variables, you should use Signals and Slots instead of events. That way, you don't need to subclass of QEvent.
-
Firstly, thanks for your help, but I have a problem I don't know very well QEvent::user, and I need create my own event with QEvent for a interruption.
Thanks for all.
-
Hi,
you need to create a custom class that inheritsQEvent
and register it withQEvent::registerEventType()
. You can then post events withQCoreApplication::sendEvent()
orQCoreApplication::postEvent()
. -
And the condition of the event, in my case when variable = 1 wherein do it carey?
-
You can put it in a member variable of your event class:
class MyEvent: public QEvent { // ... bool myCondition; };