Results 1 to 6 of 6

Thread: QTimer doesn't expire

  1. #1
    Join Date
    Sep 2010
    Location
    Bangalore
    Posts
    169
    Thanks
    59
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default QTimer doesn't expire

    Hi Everyone,

    I have 2 classes- ClassA and ClassB. ClassA has a signal called MySignal and ClassB has a slot called MySlot. And the connection is-
    Qt Code:
    1. connect(ObjClassA ,SIGNAL(MySignal()), ObjClassB,SLOT(MySlot()), Qt::BlockingQueuedConnection);
    To copy to clipboard, switch view to plain text mode 

    ClassB has a timer called MyTimer which is connected to MyTimeoutSlot in the same class.
    And MySlot is as follows-
    Qt Code:
    1. void ClassB::MySlot()
    2. {
    3. MyTimer.start(2000); //2 secs
    4. }
    5.  
    6. void ClassB::MyTimeoutSlot()
    7. {
    8. qDebug("MyTimer expired");
    9. }
    To copy to clipboard, switch view to plain text mode 

    The scenario is such that MySignal is emitted continuously (synchronization is taken care of, I mean only after MyTimeoutSlot is finished executing then only next emission of MySignal happens). But what I observed is that sometimes MyTimer doesn't start or worst doesn't expire (I am not sure which among these two is happening).
    Since QTimer is being started inside a slot whose connection type is BlockingQueuedConnection, is that causing an issue?
    Has someone before encountered such issues wherein QTimer doesn't start or expire?

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

    Default Re: QTimer doesn't expire

    Is the event loop running during those 2 seconds?
    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
    Location
    Bangalore
    Posts
    169
    Thanks
    59
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QTimer doesn't expire

    Quote Originally Posted by wysota View Post
    Is the event loop running during those 2 seconds?
    Yes, event loop is running as ClassB in my case is actually a QWidget class. When ever it receives some data in MySlot(), it displays them in the widget and then when timer expires, the widget is reset.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,419
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QTimer doesn't expire

    Just to be sure: ObjClassA and ObjClassB live in different threads, right?


    Cheers,
    _

  5. #5
    Join Date
    Sep 2010
    Location
    Bangalore
    Posts
    169
    Thanks
    59
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QTimer doesn't expire

    Quote Originally Posted by anda_skoa View Post
    Just to be sure: ObjClassA and ObjClassB live in different threads, right?
    Yes yes, both the objects are in different threads.
    There are very high chances of some bug being present in my code and I am trying very hard to detect where the bug could be. Meanwhile I just wanted to know if there are possibilities of a QTimer not starting or not expiring. Can some condition arise wherein inspite of the event loop running QTimer doesn't function properly?

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

    Default Re: QTimer doesn't expire

    Quote Originally Posted by sattu View Post
    Yes yes, both the objects are in different threads.
    Does each thread run its own event loop?
    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. Replies: 1
    Last Post: 25th October 2012, 19:47
  2. Replies: 15
    Last Post: 4th August 2012, 19:11
  3. QTimer event doesn't fire when resizing windows
    By stef13013 in forum Qt Programming
    Replies: 0
    Last Post: 3rd August 2012, 14:55
  4. QTimer in QThread doesn't start or timeout
    By Boron in forum Qt Programming
    Replies: 9
    Last Post: 21st October 2011, 13:51
  5. Replies: 1
    Last Post: 6th April 2006, 12:24

Tags for this Thread

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.