This is my header:
#ifndef ALARMH_H
#define ALARMH_H
{
Q_OBJECT
public:
{
// code here
}
{
// code here
}
void checkAlarm()
{
connect(timer, SIGNAL(timeout()), this, SLOT(checkTime()));
qDebug() << timer->timerId();
timer->start(100);
}
private:
signals:
void soundAlarm();
private slots:
void checkTime()
{
qDebug() << "check ....";
}
};
#endif // ALARMH_H
#ifndef ALARMH_H
#define ALARMH_H
class Alarm : public QObject
{
Q_OBJECT
public:
Alarm(QString file)
{
// code here
}
int parseXML(QDomDocument doc, QString file)
{
// code here
}
void checkAlarm()
{
QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(checkTime()));
qDebug() << timer->timerId();
timer->start(100);
}
private:
QString alarmName;
QTime alarmTime;
QDate alarmDate;
QString alarmSound;
QString alarmMessage;
QString alarmApp;
QString alarmAppArg;
signals:
void soundAlarm();
private slots:
void checkTime()
{
qDebug() << "check ....";
}
};
#endif // ALARMH_H
To copy to clipboard, switch view to plain text mode
I use it in .cpp:
Alarm a(filename);
a.checkAlarm();
Alarm a(filename);
a.checkAlarm();
To copy to clipboard, switch view to plain text mode
But the timer somehow does not call the SLOT once it's timed out. Probably my mistake, but where?
Bookmarks