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. QEventLoop and platform idle processing
Forum Updated to NodeBB v4.3 + New Features

QEventLoop and platform idle processing

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 1.0k 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.
  • C Offline
    C Offline
    chopper
    wrote on last edited by
    #1

    I've got some utilities written using Qt and the utilities are built as part of a framework that non Qt applications can use.

    Using iOS as an example, I've got a swift single view app test client that uses these utilities nicely - including networking calls (because the networking calls happen in a child thread where I've got a Qt Event Loop operating) - everything works great so far.

    Now, I'd like to make some of the calls into my utilities asynchronous (they are currently synchronous only) and want to allow clients to supply callbacks to my utilities.

    Nothing special about this at this point; however, I would like to execute those callbacks in the context of the original calling thread.

    If that was the main thread of a Qt application, this would be trivial - I'd use a signal and the Qt application event loop would receive it. It's not though.

    I can guarantee that it's the main UI thread of the application - so I am wondering does Qt offer an approach that can integrate a QEventLoop with the native event loop of the main thread (e.g. performing the QEventLoop processing when the native loop is idle) so that my utility code can setup a slot on the main thread that can be signaled from my utilities' child threads?

    Barring that, is it possible to use a QEventLoop without calling Exec to enter the loop and manually pump it myself when necessary? (E.g., I spawn a native timer on the platform in question and pump Qt messages in the QEventLoop)?

    Thanks! :)

    JonBJ 1 Reply Last reply
    0
    • C chopper

      I've got some utilities written using Qt and the utilities are built as part of a framework that non Qt applications can use.

      Using iOS as an example, I've got a swift single view app test client that uses these utilities nicely - including networking calls (because the networking calls happen in a child thread where I've got a Qt Event Loop operating) - everything works great so far.

      Now, I'd like to make some of the calls into my utilities asynchronous (they are currently synchronous only) and want to allow clients to supply callbacks to my utilities.

      Nothing special about this at this point; however, I would like to execute those callbacks in the context of the original calling thread.

      If that was the main thread of a Qt application, this would be trivial - I'd use a signal and the Qt application event loop would receive it. It's not though.

      I can guarantee that it's the main UI thread of the application - so I am wondering does Qt offer an approach that can integrate a QEventLoop with the native event loop of the main thread (e.g. performing the QEventLoop processing when the native loop is idle) so that my utility code can setup a slot on the main thread that can be signaled from my utilities' child threads?

      Barring that, is it possible to use a QEventLoop without calling Exec to enter the loop and manually pump it myself when necessary? (E.g., I spawn a native timer on the platform in question and pump Qt messages in the QEventLoop)?

      Thanks! :)

      JonBJ Online
      JonBJ Online
      JonB
      wrote on last edited by JonB
      #2

      @chopper

      does Qt offer an approach that can integrate a QEventLoop with the native event loop of the main thread (e.g. performing the QEventLoop processing when the native loop is idle)

      A similar(-ish?) question was asked recently. At least have a read through https://forum.qt.io/topic/104641/how-to-combine-two-eventloops-into-one.

      1 Reply Last reply
      1

      • Login

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