Qtconcurrent, multithread, invoke
-
hi, i want to show MyDialog by using concurrent
MyDialog is created in mainClass.
i try to call MyDialog in anotherClass by using concurrent
but..
below is my code and error
<main.cpp>
QtConcurrent::run(myDialogClass, &MyDialogClass::print, QString::fromLocal8Bit("show dlg"));<MyDialogClass.cpp>
void MyDialogClass::print(QString msg)
{
this->setVisible(true); // error (cannot send events to objects owned by a different thread.)i think that it is mainThread, non-mainthread problem
I solved a similar problem by using invoke method in c #.
This is a feature that forces it to be executable in other classes.Can i do something similar in qt?
-
Yes it thread issue. You need to use in main thread only.
-
Yes it thread issue. You need to use in main thread only.
-
That is the right way.