[Interest] BUG? QTimer in QThread
Sensei
senseiwa at gmail.com
Tue May 13 13:54:37 CEST 2014
On 13/05/14 13:34, André Somers wrote:
> I think the root of your problem may be that you are starting your timer
> from the constructor of myClass, and then move the instance of myClass
> to a thread. What happens if you do something like this?
>
> Q_SLOT myClass::start()
> {
> inThread_ = new QTimer(this);
> connect(inThread_, SIGNAL(timeout()), this, SLOT(dummy()));
> inThread_->start(1000);
> }
>
> The class is created this way in my QMainWindow:
>
> inThreadThread_ = new QThread(this);
> inThread_ = new myClass();
> connect(inThreadThread, SIGNAL(started()), inThread_, SLOT(start()));
> inThread_->moveToThread(inThreadThread_);
> inThreadThread->start();
Thanks André, this small adjustment made the trick!
Thank you!
More information about the Interest
mailing list