I want to wait for 2 seconds n then trigger my SLOT using SingleShot(). Though it fails, here's the error:
QObject::startTimer:QTimer can only be used with threads started with QThread
{
Q_OBJECT
public:
explicit FuelSystem
(QObject *parent
= 0);
void init();
signals:
public slots:
void updateMyData();
void DSLFL_catchInitSignal();
....
class FuelSystem : public QObject
{
Q_OBJECT
public:
explicit FuelSystem(QObject *parent = 0);
void init();
signals:
bool DSLFL_SendToRS485(QByteArray );
void DSLFL_SendToProducer(QByteArray);
public slots:
void updateMyData();
void DSLFL_catchInitSignal();
void DSLFL_DataReceive(QByteArray );
....
QTimer *pumpLifePeriodTimer;
QTimer *pump83PercLifePeriod;
QTimer *waterEvacuateTimer;
QTimer *updateDataTimer;
To copy to clipboard, switch view to plain text mode
if(data.at(3) == FUEL_SYSTEM)
{
qDebug() << "FUEL_SYSTEM";
if(data.at(4) == 0x01)
{
qDebug() << "Lower Sensor= 0x01";
qDebug() << "STARTING PUMP..";
command_startPump.append(FUEL_SYSTEM);
command_startPump.append(FUEL_PUMP);
command_startPump.append(0x01);
emit DSLFL_SendToRS485(command_startPump);
qDebug() << "OPENING SV_15";
command_SV15.append(FUEL_SYSTEM);
command_SV15.append(DSLFL_ST_SV_15);
command_SV15.append(0x01);
emit DSLFL_SendToRS485(command_SV15);
}
if(data.at(3) == FUEL_SYSTEM)
{
qDebug() << "FUEL_SYSTEM";
if(data.at(4) == 0x01)
{
qDebug() << "Lower Sensor= 0x01";
qDebug() << "STARTING PUMP..";
command_startPump.append(FUEL_SYSTEM);
command_startPump.append(FUEL_PUMP);
command_startPump.append(0x01);
emit DSLFL_SendToRS485(command_startPump);
qDebug() << "OPENING SV_15";
command_SV15.append(FUEL_SYSTEM);
command_SV15.append(DSLFL_ST_SV_15);
command_SV15.append(0x01);
emit DSLFL_SendToRS485(command_SV15);
}
To copy to clipboard, switch view to plain text mode
Well, the timers of every object are being initialized inside their own .cpp class definition file
My class only inherits QObject and not QThread. Though, I don't think that might be relevant.
I also tried passing an EventLoop as the singleshot parameter, I another error:
something like, QEvent needs Q::exec
though, as m a fresher i don't really understand EventLoop, Anyway,
To solve the first error, any helps would be appreciable
Bookmarks