[Qt-interest] connection between qthreads blocks my gui
J-P Nurmi
jpnurmi at gmail.com
Tue Dec 14 20:06:58 CET 2010
On Tue, Dec 14, 2010 at 8:25 PM, franki <franki at franki.eu.org> wrote:
> Hi all,
>
> I have some gui class (mainClass), inside that class I created two classes
> which subclass QThread, one of which is sending/receiving data from rs232,
> lets say rs232Thread, second one is sending signal to start reading from
> rs232,lets say cronThread. Connection is defined inside mainClass like this:
> connect(cronThread,SIGNAL(startChecking()),rs232Thread,SLOT(readWrite()),Qt::QueuedConnection)
>
> Problem is, that this readWrite function blocks my entire gui when running,
> and as I read somewhere in case of QueuedConnection, the SLOT is executed
> inside receiver's thread, so why is this blocking my gui?
>
> The only way I can do it without blocking gui is to place function readWrite
> inside run() of this rs232Thread and connect signal from cronThread to some
> function (defined in rs232Thread) which starts run().
>
> What am I doing wrong? Is this a problem that connection between this two
> threads is defined inside mainClass (which is gui thread) ? Or there is
> something else?
Hi,
Be careful with having slots in QThread subclasses. Check this
arcticle: http://labs.qt.nokia.com/2010/06/17/youre-doing-it-wrong/.
--
J-P Nurmi
More information about the Qt-interest-old
mailing list