Error when using QMetaObject::invokeMethod( /*param*/, /*param*/, Qt::QueuedConnection, Q_ARG(QString, /*param*/))
-
What did you try so far? Why do you need this at all?
-
-
If you want to modify any element of QML from C++ then better create a QObject, export it to QML and make a binding.
-
Connections with QML elements must be of type Qt::DirectConnection so if you want to invoke a method and pass it a string you must use
QMetaObject::invokeMethod(obj, "foo", Qt::DirectConnection, Q_ARG(QString, "bar"));
-
-
@eyllanesc said in Error when using QMetaObject::invokeMethod( /*param*/, /*param*/, Qt::QueuedConnection, Q_ARG(QString, /*param*/)):
- Connections with QML elements must be of type Qt::DirectConnection so if you want to invoke a method and pass it a string you must use
QMetaObject::invokeMethod(obj, "foo", Qt::DirectConnection, Q_ARG(QString, "bar"));
Can you reference anything to support the direct connection requirement? The commit history going back to 4.7 development uses a direct connection for QML property bindings, but that could be for efficiency.
A test program shows that auto, queued, and blocking queued connections all work with 5.15.5, given the relevant threading restrictions are followed.
- Connections with QML elements must be of type Qt::DirectConnection so if you want to invoke a method and pass it a string you must use
-