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. Getting the signal during operation the cycle.
Forum Updated to NodeBB v4.3 + New Features

Getting the signal during operation the cycle.

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 817 Views 1 Watching
  • 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.
  • T Offline
    T Offline
    Trikrista
    wrote on last edited by
    #1

    Suppose we have a thread in which there is a cycle that can be run for a long time.

    Is it possible that thread could periodically check the received signals during the run of the cycle?

    I'm sorry for my bad English

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Yes. You just need to let the event loop process the signals and events in it's queue. This can be done in multiple ways, for example using "QEventLoop::processEvents()":http://qt-project.org/doc/qt-5/qeventloop.html#processEvents

      Be careful when using that function - it will process events and signals, which means that a slot/ event handler can be invoked when you call processEvents(). That slot may modify your object, and it will change the way your cycle is working. You need to check your code.

      Other possibility is to - for example - divide your cycle into separate methods, that are invoked using Qt::QueuedConnection. This way, the event loop will be automatically invoked when one function ends, process some events, then call your queued "cycle" slot.

      (Z(:^

      1 Reply Last reply
      0
      • T Offline
        T Offline
        Trikrista
        wrote on last edited by
        #3

        Thank you. I used second option

        I'm sorry for my bad English

        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