Quantcast
Channel: Qt DevNet forums: Qt Quick 1283365070**
Viewing all articles
Browse latest Browse all 4972

Unit test for QML

$
0
0
I have written a couple of unit tests to test my QMLs already – passing values to QML, call functions and reading properties.         int argc(5);     char** argv = new char *[5];     argv[0] = "";     argv[1] = "";     argv[2] = "";     argv[3] = "";     argv[4] = "";     QGuiApplication app(argc, argv);     QQmlEngine engine;       QQmlComponent component(&engine, QUrl("qrc:/myTest/Test.qml"));     m_object = component.create();     QMetaObject::invokeMethod(m_object, "myMethod", Q_ARG(QVariant, "test test"));     QString str = QQmlProperty(m_object, "myString").read().toString(); This is working perfectly fine as long as I do not call any methods on the Canvas which use the context2d. import QtQuick 2.0   Item {     property string myString     Canvas     {         id: canvas     }       function myMethod(str)     {         myString = str     } } If I call methods on the context2d, I get the following message: Unable to use getContext() at this time, please wait for available: true I guess I need to make the canvas visible to test it? Are there any suggestions of how to do that or how I can “fake” the availability?

Viewing all articles
Browse latest Browse all 4972

Trending Articles