Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to know is exist any events in queue?
QtWS25 Last Chance

How to know is exist any events in queue?

Scheduled Pinned Locked Moved General and Desktop
7 Posts 2 Posters 2.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Milovidov
    wrote on last edited by
    #1

    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!

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      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.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Milovidov
        wrote on last edited by
        #3

        [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.

        1 Reply Last reply
        0
        • raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          so how do come into your destructor?!

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • M Offline
            M Offline
            Milovidov
            wrote on last edited by
            #5

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

            1 Reply Last reply
            0
            • raven-worxR Offline
              raven-worxR Offline
              raven-worx
              Moderators
              wrote on last edited by
              #6

              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.

              --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
              If you have a question please use the forum so others can benefit from the solution in the future

              1 Reply Last reply
              0
              • M Offline
                M Offline
                Milovidov
                wrote on last edited by
                #7

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

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved