PDA

View Full Version : QTimer with Qextserialport



jjbabu
6th November 2008, 06:30
Hi,
Here my task is writing the data to the rs-232 port with maintaining some delay.i used qextserialport for writing the data.
My task requires after writing the "nsheet" to the port maintain some delay and after i have to write sheet parameters,for that i used singleshot function of Qtimer,but after writing the "nsheet" my timer will not execute corresponding slot,hyperterminal will not display sheet parameters.
can anybody solve my problem.
thanks.

QByteArray nsheet("B0");
nsheet.append("0");
nsheet.append(QString::number(counter,10));
nsheet.append("@");
port->open(QIODevice::ReadWrite);
port->write(nsheet);
if (ui.checkBox->isChecked())
QTimer::singleShot(200,this,SLOT(SHEET1(sheet1)))



void RadarControl::SHEET1(QByteArray &sheet1)
{
QByteArray sheet("");
sheet.append(sheet1);
sheet.remove(0,sheet1.indexOf("C",0)+1);
sheet.prepend("C1");
sheet.append("@");
port->open(QIODevice::ReadWrite);
port->write(sheet);
}

jacek
6th November 2008, 23:15
You can't pass arguments in SLOT and SIGNAL macros. You have to store sheet1 somewhere else. For example you can write a custom class that will emit a signal with a parameter after a timeout.