Creating a dynamic QML component from a non Qt thread
Hi All,
My application has a qml view. I'm creating a dynamic component for a messagebox developed in QML using QQmlComponent.
I have a non-Qt class which needs to create this dynamic component on the the qml view.
However, I get this error that can't create this component on the main thread.
Kindly suggest how can I create this component on a non-qt thread to display on the qt thread.
Re: Creating a dynamic QML component from a non Qt thread
The other thread needs to send a signal or event to the main thread which then creates the component.
Cheers,
_
Re: Creating a dynamic QML component from a non Qt thread
Thanks anda_skoa for the suggestion...
Since it's not a qt class emitting signals is ruled out.. Could you explain how do i pass an event to the main thread to create this component?
Kindly advice
Re: Creating a dynamic QML component from a non Qt thread
You can either user QMetaObject::invokeMethod with Qt::QueuedConnection to invoke a lot on an object in the main thread or use QCoreApplication::postEvent() to send a custom event to an object in the main thread.
Cheers,
_