[Interest] QTimer and QThread
Tomasz Olszak
olszak.tomasz at gmail.com
Wed Jul 31 11:20:10 CEST 2013
2013/7/31 Alexander Syvak <alexander.svk at gmail.com>
> Here's the snippet below from implementation of the run method. The class
> inherits a class inheriting QThread.
> ...
> screenshot_qtmr = new QTimer;//(this);
>
> screenshot_qtmr->moveToThread(this);
>
> qDebug() << connect(screenshot_qtmr, SIGNAL(timeout()), this, SLOT(on_screenshot_timeout()));
>
> qDebug() << connect(this, SIGNAL(kill_tmr()), screenshot_qtmr, SLOT(stop()));
>
> screenshot_qtmr->start(freq*1000);
>
> anal_qmr = new QTimer;//(this);
>
> anal_qmr->moveToThread(this);
>
> qDebug() << connect(anal_qmr, SIGNAL(timeout()), SLOT(on_analize_timeout()));
>
> qDebug() << connect(this, SIGNAL(kill_tmr()), anal_qmr, SLOT(stop()));
>
> anal_qmr->start(state_analizer_tmr_interval);
>
> if ( !state_analizer_tmr_id ) return;
> exec(); while ( !stop );
>
> }
>
> Here's an ouput
> run() "./13_7_31_10_49_2_974"
>
> "./13_7_31_10_49_2_974 exists"
>
> "./13_7_31_10_49_2_974 has 'write' permission for other"
>
> "./13_7_31_10_49_2_974/S0 directory was created"
>
> true
>
> true
>
> true
>
> true
>
> run() "./13_7_31_10_49_2_974"
>
> "./13_7_31_10_49_2_974 exists"
>
> "./13_7_31_10_49_2_974 has 'write' permission for other"
>
> "./13_7_31_10_49_2_974/S1 directory was created"
>
> true
>
> true
>
> true
>
> true
>
>
> It never enters those method specified on timeout(). Why?
>
>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
>
Did you check value of state_analizer_tmr_interval?
Anyway I strongly suggest to read some docs before using QThread:
http://qt-project.org/doc/qt-5.0/qtcore/thread-basics.html
and this:
http://blog.qt.digia.com/blog/2010/06/17/youre-doing-it-wrong/
Subclassing QThread is often error prone and bad (not Qt way) design.
--
regards Tomasz Olszak
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130731/83780fe7/attachment.html>
More information about the Interest
mailing list