PDA

View Full Version : Mobile App Development with Qt 5.3



juracist
7th August 2014, 21:21
Is there any thorough tutorial for developing mobile applications with Qt 5.3?
I didn't find any good tutorial or well described step by step example. Almost all QML and Qt Quick tutorials and examples are old.

It would be great if someone here could help me and answer just some of numerous questions.


1. How to start? The app is supposed to run on Android and iOS devices. Create new Qt Quick Application project or something else?
2. How to create custom buttons with background color/image and text? Should it be customized Button control or Rectangle with child objects Image and text?
3. How to create and handle button_click event? Where is it handled, in C++ code behind QML file?
4. How are QML and C++ classes/files connected?
5. How to create couple of pages and navigate through them, i.e. after button click on one page, the other page should be opened?
6. Where are saved user data from application? For example, Settings page have some textboxes and value that user entered must be saved ond available after opening the app next time?


There are a lot of questions but there is no point to write them all.

anda_skoa
8th August 2014, 06:11
Is there any thorough tutorial for developing mobile applications with Qt 5.3?
I didn't find any good tutorial or well described step by step example. Almost all QML and Qt Quick tutorials and examples are old.

There wasn't much change in the things that QtQuick can do in regards of what tutorials usually cover so you should be good.
But you could also look at http://qmlbook.org/



1. How to start? The app is supposed to run on Android and iOS devices. Create new Qt Quick Application project or something else?

In general definitely good start, especially since you have just started using QtQuick.
The SDK downloads for mobile platforms might have specialized templates that also contain platform specific stuff, but since you want to target multiple platforms you'll need to combine these anyway at some point.



2. How to create custom buttons with background color/image and text? Should it be customized Button control or Rectangle with child objects Image and text?

I would go for QtQuick.Controls Button, but a custom button type would work as well for that use case.



3. How to create and handle button_click event? Where is it handled, in C++ code behind QML file?

The button has a "clicked" signal, so in QML you can have an "onClicked" signal handler.
If you are using QtQuick.Controls Button, you can also associate an Action with the button and react to its "triggered" signal.
If the reaction is something simple it is often done directly in QML, more complex tasks are usually better delegated to a C++ method.



4. How are QML and C++ classes/files connected?

You can export objects from C++, pass objects from QML to C++ and have QML create objects that are implemented in C++.



5. How to create couple of pages and navigate through them, i.e. after button click on one page, the other page should be opened?

Multiple options really.
One way is to create all screens upfront and change their visbility as needed.
Another option is to use Loader to load pages or parts of pages on demand.
In either case using a statemachine might come in handy as well.



6. Where are saved user data from application? For example, Settings page have some textboxes and value that user entered must be saved ond available after opening the app next time?

QSettings.

Cheers,
_