{
Q_OBJECT
private:
MainWindow *w;
public:
void run();
public slots:
void ToDo();
};
class MyThread : public QThread
{
Q_OBJECT
private:
MainWindow *w;
QTimer *timer;
public:
MyThread( QObject* parent );
void run();
public slots:
void ToDo();
};
To copy to clipboard, switch view to plain text mode
MainWindow mw;
{
// nothing to do !!!
}
void MyThread::run()
{
mw.show();
connect(timer,SIGNAL(timeout()), this, SLOT(ToDo()));
timer->setInterval(2009);
timer->start();
return a.exec();
}
void MyThread::ToDo() {
long i=0,h=0,m=0,s=0;
while(i<3)
{
std::string str = "Time: ";
char msg[100];
Converter(gTime,h,m,s);
sprintf(msg,"%02ld:%02ld:%02ld",h,m,s);
str += msg;
w
->setText
(QString::fromUtf8(str.
c_str(),str.
size()));
sleep(1);
i++;
gTime--;
}
a.closeAllWindows();
}
int main()
{
MyThread mt(0);
mt.start();
mt.wait();
}
MainWindow mw;
MyThread::MyThread( QObject* parent ) : QThread( parent )
{
// nothing to do !!!
}
void MyThread::run()
{
mw.show();
timer = new QTimer(this);
connect(timer,SIGNAL(timeout()), this, SLOT(ToDo()));
timer->setInterval(2009);
timer->start();
return a.exec();
}
void MyThread::ToDo() {
long i=0,h=0,m=0,s=0;
while(i<3)
{
std::string str = "Time: ";
char msg[100];
Converter(gTime,h,m,s);
sprintf(msg,"%02ld:%02ld:%02ld",h,m,s);
str += msg;
w->setText(QString::fromUtf8(str.c_str(),str.size()));
sleep(1);
i++;
gTime--;
}
a.closeAllWindows();
}
int main()
{
MyThread mt(0);
mt.start();
mt.wait();
}
To copy to clipboard, switch view to plain text mode
Bookmarks