I am currently creating a thread.
If this thread wants to communicate with the main thread in order to interact with the graphical interface, it gives out signals that are connected to the slots in the main widget thread. This works great.
However, for this solution, I need to go back to my original GUI form and add slots to it.
I wanted to know if I can just do this using lambda functions. For example, in the following example, the class fooruns in a separate thread. Like this
QObject::connect(this,&myclass::someSignal,
[](std::string msg)
{
QMessageBox::information(mptr,"Some title",
msg.c_str(),QMessageBox::StandardButton::Ok);
});
This gives an error that the widget must be created in the GUI thread. And I understand that.
I wanted to know if there is a way to specify to run this slot on an instance mptr. Just like we used the old Qt signal slotQObject::connect
source
share