Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Digital clock (using QTimer) [SOLVED]
Philili last edited by
I'm trying to code a simpler digital clock, adapted from the tutorial here : http://doc.qt.nokia.com/4.2/widgets-digitalclock.html
There are lots of error in the debug:
Undefined reference to 'vtable for DigitalClock'
Undefined reference to 'DigitalClock::StaticMetaObject'
Undefined reference to 'qMain(int, char**)'
collect 2: id returned 1 exit status
Here's the code :
class DigitalClock : public QLabel
DigitalClock(QWidget *parent = 0);
QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(showTime()));
showTime(); setWindowTitle(tr("Digital Clock")); resize(150, 60);
QDateTime time = QDateTime::currentDateTime();
QString text = time.toString();
daviddoria last edited by
Did you use their included main.cpp? It doesn't look like they included a .pro file - did you use qmake to configure before you tried to build?
010110102 last edited by
Fairly often these problems occur if something is not correctly included, check your .pro file for errors and if you have a main... well if you even use a main function, it would help if you would show the whole code.