#include "mainwindow.h" #include <QApplication> #include <QDebug> #include <QThread> class MyFirstThread : public QThread { private: void run() { while(1) { qDebug() << "MyFirstThread"; sleep(2); } } }; class MySecondThread : public QThread { private: void run() { while(1) { qDebug() << "MySecondThread"; sleep(4); } } }; int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; w.show(); MyFirstThread t1; MySecondThread t2; t1.start(); t2.start(); return a.exec(); }