[Interest] Project structure for multi-platform mobile devices
luca.bonifacio at bbv.ch
Mon May 5 16:51:20 CEST 2014
I have some news for you. Last week I found some time to spend into my multiplatform (Android and iOS) project and now everything works perfectly! I can run my application on iOS, Android and Desktop (Mac, Linux and Windows).
From: Tim O' Callaghan [mailto:tocallaghan at meyn.com]
Sent: Mittwoch, 30. April 2014 10:10
To: Luca Bonifacio
Subject: RE: Project structure for multi-platform mobile devices
I'm thinking of doing something similar. But before I put some more effort into it, can I ask How has QT worked out for you for mobile multiplatform?
From: interest-bounces+tocallaghan=meyn.net at qt-project.org<mailto:interest-bounces+tocallaghan=meyn.net at qt-project.org> [mailto:interest-bounces+tocallaghan=meyn.net at qt-project.org] On Behalf Of Luca Bonifacio
Sent: woensdag 23 april 2014 10:19
To: interest at qt-project.org<mailto:interest at qt-project.org>
Subject: [Interest] Project structure for multi-platform mobile devices
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.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Interest