Closing program with threads with the close bottom
General and Desktop
2
Posts
2
Posters
1.1k
Views
1
Watching
-
wrote on 29 Dec 2012, 14:42 last edited by
Dear,
I'm having a program that runs threads and when I close the app via the X button in the right corner then the program crashes because the threads keeps running.
How can I program the red x for closing the program so that the program stops correct without errors?
This is how I start my thread:
@ QFuture<void> future = QtConcurrent::run(thread,&pars);@
Kind regards,
-
Hello browser90,
Have a look at the example under "QWidget::closeEvent()":http://qt-project.org/doc/qt-5.0/qtwidgets/qwidget.html#closeEvent
Unfortunately, you can't cancel a thread started by QtConcurrent::run(). You could hide() your window, wait for the thread to finish, then quit your program.
1/2