Why bother with QThreads? Just use QtConcurrent::run(). Here:
...
connect(myButton, SIGNAL(clicked()), SLOT(runMyFunctionInAnotherThread()));
...
void myFunction() {
// This function is not meant to be run in the GUI thread
}
...
void MyClass::runMyFunctionInAnotherThread() {
QtConcurrent::run(myFunction);
}
...
connect(myButton, SIGNAL(clicked()), SLOT(runMyFunctionInAnotherThread()));
...
void myFunction() {
// This function is not meant to be run in the GUI thread
}
...
void MyClass::runMyFunctionInAnotherThread() {
QtConcurrent::run(myFunction);
}
To copy to clipboard, switch view to plain text mode
Bookmarks