Unsolved Multithreading using qt
-
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? -
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();
-
@jish
there are different possibilities to use threading in Qt.
You should read Thread Basics and Multithreading Technologies in QtIf you already have the parsing logic, moving to threads shouldn't be a big deal anymore.
-
Use QThread, peferrably with worker objects - to save yourself from the trouble with locking and mutexes.
-
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
-
@beecksche Thank you. But for each start there should be a run function .right?
-
@sierdzio [0_1499160206588_qmlcommunicator.cpp](Uploading 100%) .how can i include another thread like receivefromHU
-