How to know is exist any events in queue?



  • Hello all!

    I have two threads and several connections via signals and slots between.
    I want to know is exist any signals in queue of thread object before I will delete it and if exist I want wait until all signals will handled by this object.
    Is it possbile and how to do this if possible?

    Thank you for attention!


  • Moderators

    since you only could check if in the current event loop are pending events anyways, you can delete a QObject instance by QObject::deleteLater(). It will cause the object to be deleted in the next event loop iteration.



  • [quote author="raven-worx" date="1379934894"]since you only could check if in the current event loop are pending events anyways, you can delete a QObject instance by QObject::deleteLater(). It will cause the object to be deleted in the next event loop iteration.[/quote]

    Problem that I don't can call @QObject::deleteLater()@ because I already want to check this in destructor of QThread object.


  • Moderators

    so how do come into your destructor?!



  • I want to know is exist signals in query when I already in destructor of QThread object (I can just to inherite from QThread).


  • Moderators

    with what portion of code is your thread object deleted?!
    Just use deleteLater() in this place and you wont need any checks, since deleteLater() ensures that it will be deleted in the next event loop iteration.
    So your thread will receive all events from the current event loop iteration before it gets deleted.



  • Ok, I understand, may be this will help! Thank you!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.