On 28 February 2016 at 00:26, Alejandro Exojo <s...@badopi.org> wrote:
>
> El Saturday 27 February 2016, Thiago Macieira escribió:
> > On sábado, 27 de fevereiro de 2016 11:45:50 PST Syam wrote:
> > > 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.
> >
> > Yes. The signal will be queued anyway.
>
> Will be queued without the explicit QueuedConnection? In other words, what
> does AutoConnection do here? run() is executed in another thread, but the
> QThread is in the same thread of MainWindow, right?

See http://doc.qt.io/qt-5/qt.html#ConnectionType-enum

"If the receiver lives in the thread that emits the signal,
Qt::DirectConnection is used. Otherwise, Qt::QueuedConnection is used.
The connection type is determined when the signal is emitted."

Qt checks to see which thread the signal is emitted from. Qt does not
check which thread the signal sender lives in.


Regards,
Sze-Howe
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to