PDA

View Full Version : Stopping QTimer



drinu21
15th May 2008, 13:06
Hi all,

i am using QTimer to get Data from the parallel port at a given interval.
this is the code:


getData::getData(QWidget *parent) : QWidget(parent)
{
timer = new QTimer(this);
}

void getData::set()
{
fft.Data();
parport.setPortBi();
clk = 0;
}

void getData::startTimer()
{
connect(timer, SIGNAL(timeout()),this, SLOT(getData()));
timer->start(0.2675);
}

void getData::getData()
{
if(clk<22050)
{
parport.getdata();
fft.DATA[clk] = parport.finData;
clk++;
}
else
{
timer->stop();
return;
}
}


now i want that after 22050 times it stops the timer and return. But it is not stopping and is continuing to enter the function that is connected with.

Do anyone now what i am doing wrong, or a different code that do the same function??

10x
Adrian

wysota
15th May 2008, 14:05
QTimer::start() takes an integer, not a real number, thus you are effectively passing it a "0". That's probably your problem. If you want it to tick every 0.2675s then pass 267.

drinu21
15th May 2008, 14:14
the problem is that i need 0.2675 mseconds. is there a timer for uSeconds??

wysota
16th May 2008, 09:40
No, forget it :) You'd need a real time system for that, in the first place. What is your use case?

^NyAw^
16th May 2008, 16:59
Hi,

Related to Real Time OS, could Qt be used on vxWorks or QNX OS ?