[Development] Project structure for multi-platform mobile devices

Gustavsen Richard Richard.Gustavsen at digia.com
Wed Apr 23 11:33:20 CEST 2014


When building a static application on iOS, Qt currently scans the project folder for all qml files and tries to figure out which imports they use. The result is used to copy and link the needed resources into the application.
This means that currently your qml files needs to be inside your application folder for it to work (or at least you need to add a dummy qml file there that contains all the imports needed).

-Richard


________________________________________
Fra: development-bounces+richard.gustavsen=digia.com at qt-project.org [development-bounces+richard.gustavsen=digia.com at qt-project.org] på vegne av Luca Bonifacio [luca.bonifacio at bbv.ch]
Sendt: 23. april 2014 00:38
Til: development at qt-project.org
Emne: [Development] Project structure for multi-platform mobile devices

Hi everyone

Actually, I’m getting serious problems by setting up a Qt/QML project integrating also unit tests for a multi-platform mobile application. The idea is to set up a project skeleton for the development of applications, which will run on Android and iOS; and at the same time, the unit tests will be executed on a continuous integration server.
For that purpose, I initially defined a subdirs project containing two projects: one for the application and one for the unit tests.
The HelloWorld application ran without any problems on both platforms. Also the unit test written in QML worked fine.

The problems began when I started to write my unit tests for the QML file that embeds C++ objects. By running the unit tests on the QML component that uses C++ objects, errors are displayed on the console: the C++ objects are not found. That makes also sense cause the C++ objects are set in the main.cpp file by using setContextProperty on my root context view. To get around to the problem I decided to do the following:
1.      Mock the C++ objects in my QML unit tests, and
2.      Add a new unit tests project for the C++ part.

For the first item, unfortunately, I didn’t find any information or example about how to mock a C++ object in QML.

For the second item, as I want to test the C++ objects, I decided to split my application into two parts. One part includes the application core (everything apart the main), which is statically built, instead the second part includes just the main functions which links against the application core and executes it. In the same way, I’m able to run my unit tests for my C++ objects.

Finally, I get the following project structure:
•       application-core        static built
•       application-app links against the application-core
•       unit-tests-qml  tests only QML files of application-core
•       unit-tests-qt   links against the application-core and tests only C++ objects

The new application runs without problem on Android devices, instead on iOS devices I get an error message: module "QtQuick" plugin "qtquick2plugin" not found.

Here my questions:
1.      Is it possible to mock C++ objects or others components in QML? If yes, how?
2.      Is the structure of my project correct? Or generally, how to structure complex projects?

Thank a lot in advance for every kind of helps or suggestions.

Best regards

Luca Bonifacio
_______________________________________________
Development mailing list
Development at qt-project.org
http://lists.qt-project.org/mailman/listinfo/development



More information about the Development mailing list