QtQuickTest: add custom C++ objects
-
Hi,
in my application, I register custom C++ objects that I use in the GUI afterwards. I would like to unit test my application with QtQuickTest. However, the C++ objects are not found. So how can I register them so that I can use them when unit testing my app with QtQuickTest?¨
Thanks for any help.
Best regards. -
Have you read the follwing link:
http://qt-project.org/wiki/Introduction_to_Qt_Quick_for_Cpp_developers#e70ea8482b12de725ec779f1bc55c92c -
-
Hi
I know that this link is old. But it hasn't changed in QtQuick 2. The principal is the same.Here the up to date link.
http://qt-project.org/doc/qt-5/qtqml-cppintegration-topic.htmlNow choose the link, Embedding C++ Object in QML.
http://qt-project.org/doc/qt-5/qtqml-cppintegration-contextproperties.htmlWhen you register you C++ Object with QmlContext::setContextProperty
then you should also be able to access your C++ object in QML.If this approach doesn't work, post a code example to analyse where the problem might be.
Best regards
Juergen