Solved How to create Nested QThread( Create one inside another)?
-
I have One Worker Thead
void startTcpThread()
{
QThread* thread = new QThread;
connect(thread, SIGNAL (started()), mTcpProcess, SLOT (run()));//Run
connect(mTcpProcess, SIGNAL (finished()), thread, SLOT (quit()));//Quit thread
connect(thread, SIGNAL (finished()), thread, SLOT (deleteLater()));//Delete Thread
mTcpProcess->moveToThread(thread);
thread->start();
}is it possible to create other thread inside mTcpProcess?
-
@brucezcg Sure, you can create a thread from another thread. You're already doing this when you create your first thread (it is created from the main thread).
-
@jsulm Thanks, and one more question, how to do sleep in function run() which inside my worker class (inherit from QObject)
-
-
@brucezcg
Be carefull with the sleep function, chances are high, that you’re approaching this from the wrong angle.
Especially if you’re new to Qt’s threading system, which I asume you are, from your questions in this topic. -
@J.Hilk Okay, Thanks