This is a very newbie ask....
I don't understand some QT concepts .
I want to have a Timer into a simple class.
The h file
#ifndef TIMER_H
#define TIMER_H
#include <QTimer>
class Timer
{
Q_OBJECT
public:
Timer();
void start();
public slots:
void updateTime();
};
#endif // TIMER_H
#ifndef TIMER_H
#define TIMER_H
#include <QTimer>
class Timer
{
Q_OBJECT
public:
Timer();
void start();
QTimer * m_timer;
public slots:
void updateTime();
};
#endif // TIMER_H
To copy to clipboard, switch view to plain text mode
the cpp file
#include "timer.h"
Timer::Timer()
{
}
void Timer::start(){
m_timer->interval(1000);
connect(m_timer, SIGNAL(timeout()), this, SLOT(updateTime()));
}
void Timer::updateTime(){
}
#include "timer.h"
Timer::Timer()
{
}
void Timer::start(){
m_timer=new QTimer(this);
m_timer->interval(1000);
connect(m_timer, SIGNAL(timeout()), this, SLOT(updateTime()));
}
void Timer::updateTime(){
}
To copy to clipboard, switch view to plain text mode
I have the errors :
error: no matching function for call to 'QTimer::QTimer(Timer* const)'
note: candidates are: QTimer::QTimer(const QTimer&)
error: 'connect' was not declared in this scope
Have I to create the Timer class extending QObjetc ?
What includes have I missing ?
Thanks
Bookmarks