Results 1 to 4 of 4

Thread: QBasicTimer and lightweight QT Objects :

  1. #1
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default QBasicTimer and lightweight QT Objects :

    The QT doc says :
    Unlike QTimer, QBasicTimer doesn't inherit from QObject....
    This makes QBasicTimer a more lightweight alternative to QTimer.

    Any link to lightweight QT literature or articles ?

    The code for Wiggly Example is :
    Qt Code:
    1. void AnalogClock::timerEvent(QTimerEvent *event)
    2. {
    3. if (event->timerId() == timer.timerId()) {
    4. ++step;
    5. update();
    6. } else {
    7. QWidget::timerEvent(event);
    8. }
    9. }
    To copy to clipboard, switch view to plain text mode 
    And my question is who more can call my timerEvent ? Can I delete the timerId() check ?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QBasicTimer and lightweight QT Objects :

    Quote Originally Posted by tonnot View Post
    Any link to lightweight QT literature or articles ?
    no.

    And my question is who more can call my timerEvent ?
    A subclass or superclass.
    Can I delete the timerId() check ?
    You can do anything you want.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QBasicTimer and lightweight QT Objects :

    Thanks Wisota
    You answer me to 'who more call my timerEvent' >> A subclass or superclass...
    But If I'm sure that this event are only called by me .... can i use a code without timerid() check ? or maybe occur something unexpected ?
    Thanks

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QBasicTimer and lightweight QT Objects :

    Quote Originally Posted by tonnot View Post
    But If I'm sure that this event are only called by me .... can i use a code without timerid() check ?
    If you are sure then you don't need the check. But with Qt you can't be sure unless you are sure Qt libraries you use will never be changed.

    I don't see a point in all this discussion. If you are looking for ways to make your application faster then you are looking in a wrong place, removing this check (which is probably inlined anyway) will save you less cpu cycles than the number of cpu cycles it takes to create the stack frame for the timerEvent() call. Don't look for ways to optimize highways, optimize small roads instead.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. QBasicTimer never timeout.
    By kunalnandi in forum Qt Programming
    Replies: 5
    Last Post: 30th January 2010, 07:55
  2. QTimer QBasicTimer and QObject::startTimer
    By SABROG in forum Qt Programming
    Replies: 7
    Last Post: 15th June 2009, 17:37
  3. ‎a lightweight text showing widget
    By jacum in forum Qt Programming
    Replies: 1
    Last Post: 22nd August 2007, 14:44
  4. lightweight static linking qt?
    By gfunk in forum Qt Programming
    Replies: 7
    Last Post: 16th April 2007, 04:20
  5. Replies: 7
    Last Post: 18th July 2006, 21:33

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.