Monday, December 24, 2012

Working with Cascade (2) - This is not the QML you know

Cascade supports QML syntax for UI creation. If you think this QML is the same as the QML we know from Nokia, think again.

One significant difference is the layout concept. Unlike the anchor concept for pure QML, Cascade offers three types of layout, Stack/Dock/Absolute. AbsoluteLayout is like using x,y for pure QML, Stack and Dock abstracts the layout to make it device-independent. At first StackLayout feels like Row/Column elements to me and I naturally looked for padding property to have spacing between the contained elements. The correct approach for StackLayout is to use the StackLayoutProperty to specify spaceQuota. The naming is obscured, it really is layoutPriority. The elements of the same priority are given equal amount of space. Keep this in mind when you first experiment with the layout.

The Eclipse IDE in the native SDK has QML preview feature similar to QtCreator. Unfortunately, Eclipse cannot handle Qt C++ components in attachedObjects so once you have them in your code, you can say goodbye to the preview feature. Therefore, I strongly suggest getting your UI right before connecting the bones of your Cascade app.

Speaking of IDE, in QtCreator the assets (like images, QML, splash screen, icons) are specified within .pro file. In Cascade, these are all specified in a bar-descriptor.xml. Two options not immediately obvious from the GUI interface is theme and run-in-background. They are configured by:


    <!-- Dark theme. -->
    <env var="CASCADES_THEME" value="dark"/>
   
    <!-- Run in background. -->
    <permission>run_when_backgrounded</permission>


No comments:

Post a Comment