How to call a method on a GUI object in the main thread?
I receive data in a separate Haskell (and OS) thread and want to display that data in UI. I can't call Qt methods from that thread:
QObject: Cannot create children for a parent that is in a different thread.
(Parent is QTextDocument(0x162a1f0), parent's thread is QThread(0x1416d90), current thread is QThread(0x7fc568001120)
Segmentation fault
In C++, I can simply
QMetaObject::invokeMethod(a_GUI_object, []{
// this runs in GUI thread
});
or (more complex solution) declare own signal and connect(..., receiver, ..., AutoConnection)
which runs the slot in the receiver's thread.
Neither solution is available in Qtah. What can I use? How can I run some Haskell code inside main event loop?
Edited by Yuriy Syrovetskiy