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. Run multiple QEventLoops in parallel (for QtNetwork)
QtWS25 Last Chance

Run multiple QEventLoops in parallel (for QtNetwork)

Scheduled Pinned Locked Moved Solved General and Desktop
qtnetworkqeventloopparallel
6 Posts 2 Posters 2.6k 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.
  • Q Offline
    Q Offline
    QtExchange
    wrote on 2 Mar 2016, 10:49 last edited by
    #1

    I try to extend an old program with a Qt-network support. Having a LAN communication with these libraries needs to run the .exec() of the QEventLoop to really start working (i.e.: accept connections, receive, send, etc.)

    The problem

    I don't know where this event loop is in the main program and because I vaguely know about it's design I prefer a solution that is as indipendent as possible.

    My idea

    I already checked I don't need the main-QEventLoop, and it's alright to make another one just for the networking (i.e. nesting). Unfortunately I can't figure out how to run both loops in parallel, since my program stops at the nested-.exec() and so the main program is on halt too.

    So my main intention is actually to extend the main program with a Qt-Networking, I'm open for other solutions too.

    Thanks for any advise

    1 Reply Last reply
    0
    • J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 2 Mar 2016, 11:48 last edited by
      #2

      I don't understand: if your app already have an event loop why do you need a second one?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      Q 1 Reply Last reply 2 Mar 2016, 12:12
      0
      • J jsulm
        2 Mar 2016, 11:48

        I don't understand: if your app already have an event loop why do you need a second one?

        Q Offline
        Q Offline
        QtExchange
        wrote on 2 Mar 2016, 12:12 last edited by
        #3

        @jsulm since the main event loop doesn't get triggered for some reason

        1 Reply Last reply
        0
        • J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 2 Mar 2016, 13:32 last edited by jsulm 3 Feb 2016, 13:33
          #4

          Why it isn't triggered?
          Do you block it somewhere (endless loop)?
          Instead to start a new event loop you should check what is wrong with your code.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          Q 1 Reply Last reply 4 Mar 2016, 08:15
          1
          • J jsulm
            2 Mar 2016, 13:32

            Why it isn't triggered?
            Do you block it somewhere (endless loop)?
            Instead to start a new event loop you should check what is wrong with your code.

            Q Offline
            Q Offline
            QtExchange
            wrote on 4 Mar 2016, 08:15 last edited by QtExchange 3 Apr 2016, 08:22
            #5

            @jsulm it's not my fault. After having a deeper look into the main application I realize it is not a Qt-program at all, so there will never be a .exec().

            Right now I'm thinking about making a thread for the the .exec()-loop and as it looks for now it is running the main-app and my network extension smoothly. However I'm not a pro when it comes to QEventLoops but could this generate errors or general problems with my suggested solution ? (E.g.: Is my signal/slot procedure for connecting to incomming correspondences guaranteed or may it be (because at that moment the thread was not running), that these request get lost)

            1 Reply Last reply
            0
            • J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 4 Mar 2016, 08:23 last edited by
              #6

              I never tried to start a thread with event loop in a program without main event loop (QApplication). My guess: it will work inside your thread, but you will not be able to communicate with the thread from main thread using signals/slots.

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              1

              1/6

              2 Mar 2016, 10:49

              • Login

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