Why bother with QThreads? Just use QtConcurrent::run(). Here:
Qt Code:
  1. ...
  2. connect(myButton, SIGNAL(clicked()), SLOT(runMyFunctionInAnotherThread()));
  3. ...
  4. void myFunction() {
  5. // This function is not meant to be run in the GUI thread
  6. }
  7. ...
  8. void MyClass::runMyFunctionInAnotherThread() {
  9. QtConcurrent::run(myFunction);
  10. }
To copy to clipboard, switch view to plain text mode