Call QML function directly from Qt(C++) in 4.8
I want to call the QML function directly from c++?
Hi shav, Actually I am using Qt4.8.... so QQmlEngine,QQmlComponent are not available.... please give solution for 4.8
Oh... I'm sorry I've use Qt5.3 and post sample from Qt5.3 doc. I've found this code:
QDeclarativeComponent component(&engine, "MyItem.qml");
QObject *object = component.create();
QVariant msg = "Hello from C++";
qDebug() << "QML function returned:" << returnedValue.toString();
Sorry I can't check it now because I don't have Qt 4.8 on my PC. But this code from official Qt4.8 documentation. You can use this "link":http://qt-project.org/doc/qt-4.8/qtbinding.html#calling-functions for more information.
Hi shav , It is working fine, but I can't able to access the components (like Image,rectangle) in that QML functions... while try to access below error is through .....
QObject::installEventFilter(): Cannot filter events for objects in a different thread.
QPixmap: It is not safe to use pixmaps outside the GUI thread