This is what I wrote to make a simple timer.
openSuse 11, Qt 4.5, Qt Creator, Qt GUI App
It doesn't work, I mean when I try to execute it "Hi" doesn't appear on Konsole. I tried to debug it in the constructor of the class, but gdb never goes there.
Thanks for your help
MyObject.h
Code:
#include <QtCore/QObject> #include <QtCore/QTimer> { Q_OBJECT public: MyObject(); private: QTimer *timer; private slots: void timerEvent(); };
main.cpp
Code:
MyObject::MyObject() { connect(timer, SIGNAL(timeout()), this, SLOT(timerEvent())); timer->setInterval(10); timer->start(); } void MyObject::timerEvent() { std::cout << "Hi" << std::endl; timer->start(); } int main() { MyObject mo; sleep(5); return 0; }

