[Interest] Emitting signal from QThread::run()
Syam
syamcr at gmail.com
Sat Feb 27 07:15:50 CET 2016
Hello,
Inspired from the recent discussions on QThread, I have the following
question.
I have:
class MyThread : public QThread
{
Q_OBJECT
//the constructor and other stuff
signals:
void mySignal();
protected:
virtual void run()
{
while(true)
{
//do something
if(some_condition) emit mySignal();
}
}
};
void MainWindow::someFunction()
{
MyThread *thread = new MyThread;
connect(thread, SIGNAL(mySignal()), this, SLOT(myGuiSlot()),
Qt::QueuedConnection);
thread->start();
}
//////////////////
Will the above code work fine? In myGuiSlot() I am typically manipulating
some widgets - setting the text of a QLabel etc.
--
Regards,
Syam
syamcr at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160227/60374b0c/attachment.html>
More information about the Interest
mailing list