PDA

View Full Version : error: no matching function for call to ‘QTimer:



saman_artorious
21st May 2012, 15:15
I need to set a timer in my serial class, so when the timer triggers, it calls
a slot. I get the following error when I build the program:



error: no matching function for call to ‘QTimer::singleShot(int, rsxxx* const, bool)’


Here's the code segment:



void rsxxx::DieselSwitchOff()
{
if(!DieselSwitchOff_1())
{
qDebug() << "Diesel failed to switch off..";
}

QTimer::singleShot(3000, this, DieselSwitchOff_2());
}


how should DieselSwitchOff be declared? as a public slot or a class member suffices?
also note that the DieselSwitchOff_2 return bool.
I pass the this pointer, as I want to call the singleShot in my rs485 class.

mvuori
21st May 2012, 15:57
When you look at QTimer class reference, you may notice that the last parameter is int the function call is in the examples wrapped inside a SLOT() makro, so do that and make it a public slot. I guess there may be another problem of rsxxx not being based on QObject, which is needed for that argument.

StrikeByte
21st May 2012, 16:27
If the class is not an QObject it is not possible to send the class as an argument to singleShot

The slot may be a private slot thats not a problem but maybe try:
QTimer::singleShot(3000, this, SLOT(DieselSwitchOff_2()));

What version of Qt are you using
Qt3 doesn't have the singleShot function (it uses timer->start(int,bool) the bool is for singleshot)
Qt4 does have it