c++ - How to mock a QML component -


actually i'm trying run test on qml component embeds c++ objects. unfortunately, i'm getting errors when execute tests. c++ objects aren't recognized qml file. makes sense c++ objects set in main.cpp file.

my question is: how can mock context property performing qml tests? or other said, how can unit-test mixing qt/qml code?

as understand right, got same problem i. time ago wrote mock: https://bitbucket.org/troyane/qml-cpp-template (you can use code free purposes).

take @ main.cpp, there can see 2 ways of doing things:

// 1 case: // register type , create object @ qml side qmlregistertype<cppclass>("cppclassmodule", 1, 0, "cppclass"); qqmlapplicationengine engine(qurl("qrc:///qml/main.qml")); qdebug() << "qt version: " << qversion(); // 2 case: // create object here , "move up" qml side // engine.rootcontext()->setcontextproperty("cppclass", new cppclass); 

good luck!


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -