Results 1 to 9 of 9

Thread: What is the general rule for onX methods in Qt?

  1. #1
    Join Date
    May 2009
    Posts
    133
    Thanks
    10
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default What is the general rule for onX methods in Qt?

    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?

  2. #2
    Join Date
    Jan 2006
    Location
    Frankfurt
    Posts
    500
    Thanks
    1
    Thanked 52 Times in 52 Posts
    Platforms
    MacOS X Unix/X11

    Default Re: What is the general rule for onX methods in Qt?

    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/qmetaob...ectSlotsByName

    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
    It's nice to be important but it's more important to be nice.

  3. #3
    Join Date
    May 2009
    Posts
    133
    Thanks
    10
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: What is the general rule for onX methods in Qt?

    Quote Originally Posted by axeljaeger View Post
    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/qmetaob...ectSlotsByName
    Thanks for your answer. I did not mean on_X methods you refer to, however. I meant for example
    Qt Code:
    1. void QAbstractTransition::onTransition ( QEvent * event ) [pure virtual protected]
    To copy to clipboard, switch view to plain text mode 
    and
    Qt Code:
    1. void QAbstractTransition::triggered () [signal]
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: What is the general rule for onX methods in Qt?

    Quote Originally Posted by piotr.dobrogost View Post
    Qt Code:
    1. void QAbstractTransition::onTransition ( QEvent * event ) [pure virtual protected]
    To copy to clipboard, switch view to plain text mode 
    I'd expect

    Qt Code:
    1. protected:
    2. virtual void QAbstractTransition::transitionEvent(QTransitionEvent *event) = 0;
    To copy to clipboard, switch view to plain text mode 
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

  5. #5
    Join Date
    May 2009
    Posts
    133
    Thanks
    10
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: What is the general rule for onX methods in Qt?

    Quote Originally Posted by franz View Post
    I'd expect

    Qt Code:
    1. protected:
    2. virtual void QAbstractTransition::transitionEvent(QTransitionEvent *event) = 0;
    To copy to clipboard, switch view to plain text mode 
    What do you mean?

  6. #6
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    229
    Thanks
    2
    Thanked 29 Times in 28 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: What is the general rule for onX methods in Qt?

    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 ?
    If that is not the question forget my post .

  7. #7
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: What is the general rule for onX methods in Qt?

    And where did you find QAbstractTransition:nTransition(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.
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  8. #8
    Join Date
    May 2009
    Posts
    133
    Thanks
    10
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: What is the general rule for onX methods in Qt?

    Quote Originally Posted by faldżip View Post
    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

  9. #9
    Join Date
    May 2009
    Posts
    133
    Thanks
    10
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: What is the general rule for onX methods in Qt?

    Quote Originally Posted by Boron View Post
    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.

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.