How to execute a Thread(QwtSamplingThread) for sometime and making the GUI(mainwindow) wait for 3 seconds?.
Unsolved
General and Desktop
-
Hi Guys,
I have created class filethread which inherits the QwtSamplingThread for filereading it executes one function in run()
filethread.cpp code:void Filethread::run() { scanfile() }
main.cpp
code:int main() { QApplication a(argc,argv); FileThread thread; thread.start();//this qwt thread I want it to complete the task for 3 seconds and then the compiler to star the mainwindow object which is GUI thread because this will get the data vector from the Filethread object. MainWindow w;//this should be started after the filethread object complition. w.resize(800,400); w.show(); bool endapp=a.exec(); thread.stop(); return endapp;
I want qwtthread to execute first and complete it the task for 3 seconds and after this mainwindow obj.show should execute, how to do this?
how to do this, please help. -
I think you can emit a signal when the qwt thread complete it's task.
And connect the signal to a slot of mainwindow.
Then let the mainwindow to do the things. -
Hi,
The quick and silly method:
QTimer::singleShot(3000, &w, &QMainWindow::show);