Welcome! Log In Create A New Profile

Advanced

A2 Q1: QTimer never runs?

Posted by Seymore 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
A2 Q1: QTimer never runs?
July 01, 2010 02:24PM
Hi Everyone

Was wondering if anyone could help?

I start a timer in my thread and I connect it to a function in my thread, but it seems that it never executes?

I have the following code which is like standard issue for starting a timer:

Language: C++ (QT)
QTimer *timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(updateStock())); timer->setInterval(100); timer->start();


What am I doing wrong?
Re: A2 Q1: QTimer never runs?
July 01, 2010 02:35PM
Could it be that the thread is blocking, because the timer is running?
Re: A2 Q1: QTimer never runs?
July 01, 2010 02:49PM
Hi, I don't see why it wouldn't work but you're not providing a lot of code. Like for example updateStock() function and what it is suppose to do. Know that if you give a incorrect reference to a function in the connect statement that it doesn't cause the compiler to complain. Think this is because SLOT and SIGNAL are macros. So if updateStock(), is suppose to be updateStock(SomeType) then it won't warn you.
avatar Re: A2 Q1: QTimer never runs?
July 01, 2010 03:00PM
QTimer events are only processed by the event loop. If you're using the one of QCoreApplication, are you running exec() somewhere? If yes, is the program being blocked before getting there?
Re: A2 Q1: QTimer never runs?
July 06, 2010 08:58AM
Hi

I skipped the whole timer thing and used thread sleep.

And oh, I didn't pass any variables along with the function in connect, I linked the object beforehand, i.e:

QLineEdit * le = new QLineEdit();
stockwatch->le = le;

then inside stockwatch I could just reference le->text()

thanks anyways
Sorry, only registered users may post in this forum.

Click here to login