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. Multithreading using qt
Forum Updated to NodeBB v4.3 + New Features

Multithreading using qt

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 5 Posters 2.0k Views 3 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.
  • J Offline
    J Offline
    jish
    wrote on last edited by
    #1

    i want to use multithreading in my qt program.
    My program is to continuously receive data from two message queues. After receiving data i have to parse it. so for each queue i have a parsing method. how can i run this as two seperate threads?

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

      Hi @jish,
      maybe you have a look at the QThread class, which manages threads!

      If you move your parser to the a thread and start it, the parser method should run in another thread.

      Parser *myParser = new Parser();
      myParser->moveToThread(&workerThread);
      ...
      connect(this, &MyClass::newQuery, myParser, &Parser::handleQuery);
      ...
      workerThread.start();
      
      J 1 Reply Last reply
      0
      • J jish

        i want to use multithreading in my qt program.
        My program is to continuously receive data from two message queues. After receiving data i have to parse it. so for each queue i have a parsing method. how can i run this as two seperate threads?

        raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by raven-worx
        #3

        @jish
        there are different possibilities to use threading in Qt.
        You should read Thread Basics and Multithreading Technologies in Qt

        If you already have the parsing logic, moving to threads shouldn't be a big deal anymore.

        --- 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
        2
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          Use QThread, peferrably with worker objects - to save yourself from the trouble with locking and mutexes.

          (Z(:^

          J 1 Reply Last reply
          1
          • sierdzioS Offline
            sierdzioS Offline
            sierdzio
            Moderators
            wrote on last edited by
            #5

            Wow, either the 3 of us posted simultaneously or I had some network lag - when I responded there were no other posts here :) Sorry for the noise

            (Z(:^

            1 Reply Last reply
            1
            • beeckscheB beecksche

              Hi @jish,
              maybe you have a look at the QThread class, which manages threads!

              If you move your parser to the a thread and start it, the parser method should run in another thread.

              Parser *myParser = new Parser();
              myParser->moveToThread(&workerThread);
              ...
              connect(this, &MyClass::newQuery, myParser, &Parser::handleQuery);
              ...
              workerThread.start();
              
              J Offline
              J Offline
              jish
              wrote on last edited by
              #6

              @beecksche Thank you. But for each start there should be a run function .right?

              1 Reply Last reply
              0
              • sierdzioS sierdzio

                Use QThread, peferrably with worker objects - to save yourself from the trouble with locking and mutexes.

                J Offline
                J Offline
                jish
                wrote on last edited by
                #7

                @sierdzio [0_1499160206588_qmlcommunicator.cpp](Uploading 100%) .how can i include another thread like receivefromHU

                1 Reply Last reply
                0
                • VRoninV Offline
                  VRoninV Offline
                  VRonin
                  wrote on last edited by
                  #8

                  https://mayaposch.wordpress.com/2011/11/01/how-to-really-truly-use-qthreads-the-full-explanation/

                  "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                  ~Napoleon Bonaparte

                  On a crusade to banish setIndexWidget() from the holy land of Qt

                  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