PDA

View Full Version : What is the general rule for onX methods in Qt?



piotr.dobrogost
14th August 2009, 21:33
Is there a general rule for the moment of invocation of onX methods in Qt in regard to

1. object's state change
2. side effects?

axeljaeger
16th August 2009, 09:54
The on_XX-methods in Qt are a mechanism introduced in Qt 4.0 to connect hand written code to designer generated form classes. See http://doc.trolltech.com/4.5/qmetaobject.html#connectSlotsByName

In the name of the method, you see wether the name of the signal is written in the past (clicked) or in the future (aboutToBeClicked). Most objects only provide signals that are emitted AFTER the state has changed, e.g. clicked, triggered

piotr.dobrogost
16th August 2009, 10:51
The on_XX-methods in Qt are a mechanism introduced in Qt 4.0 to connect hand written code to designer generated form classes. See http://doc.trolltech.com/4.5/qmetaobject.html#connectSlotsByName

Thanks for your answer. I did not mean on_X methods you refer to, however. I meant for example

void QAbstractTransition::onTransition ( QEvent * event ) [pure virtual protected]
and

void QAbstractTransition::triggered () [signal]

franz
16th August 2009, 20:17
void QAbstractTransition::onTransition ( QEvent * event ) [pure virtual protected]

I'd expect


protected:
virtual void QAbstractTransition::transitionEvent(QTransitionEv ent *event) = 0;

piotr.dobrogost
16th August 2009, 21:17
I'd expect


protected:
virtual void QAbstractTransition::transitionEvent(QTransitionEv ent *event) = 0;

What do you mean?

Boron
17th August 2009, 18:36
To rephrase your question:
How is a method that is marked as [pure virtual protected] in Qt docs declared in the Qt source code?

If that is the question why don't you look in the source code :confused:?
If that is not the question forget my post :cool:.

faldzip
17th August 2009, 23:02
And where did you find QAbstractTransition::onTransition(QEvent *event)? there is no such thing in Qt sources and Qt Assistant. Only onX methods are in WebCore which wasn't designed by Trolls, just ported would be my guess.

So it's hard to say what is the general rule for onX methods in Qt as there are no such methods in Qt (at least in my Qt sources 4.5.0). But Im guessing from the method declaration you pasted that it's just an event handler so it is invoked when event loop is processing events which should be processed in that onX method.

piotr.dobrogost
17th August 2009, 23:08
So it's hard to say what is the general rule for onX methods in Qt as there are no such methods in Qt (at least in my Qt sources 4.5.0).

They are in master and will be part of 4.6

piotr.dobrogost
17th August 2009, 23:10
To rephrase your question:
How is a method that is marked as [pure virtual protected] in Qt docs declared in the Qt source code?

There's nothing strange in this. Pure means they must be overriden. That's all.