Category:Tools::QtComplex: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
[toc align_right="yes" depth="3"]
[toc align_right="yes" depth="3"]


= Qt-Complex (1.1.0 Harmattan release) =
= Qt-Complex (1.1.0 Harmattan release) =
Line 5: Line 5:
[[Image:https://projects.developer.nokia.com/Qt_Complex/files/QtComplexHarmattan06x500.jpg|Qt-Complex in action]]
[[Image:https://projects.developer.nokia.com/Qt_Complex/files/QtComplexHarmattan06x500.jpg|Qt-Complex in action]]


This article is intended as a quick user guide for the Qt-Complex framework installation and usage, 1.1.0 Harmattan release. A complete documentation can be found on the &quot;'''project wiki pages'''&quot;:https://projects.developer.nokia.com/Qt_Complex/wiki.<br />Qt-Complex is a code package that can be added to any Qt-Quick project - also existing - giving the possibility to manage complex components like Ovi maps navigation, animated toolbars, grouped switches etc. Following the QML philosophy Qt-Complex is hyerarchical so you find simple elements (button switch, button, standard toolbar, …) and complex elements that reuses the same base objects.
This article is intended as a quick user guide for the Qt-Complex framework installation and usage, 1.1.0 Harmattan release. A complete documentation can be found on the "'''project wiki pages'''":https://projects.developer.nokia.com/Qt_Complex/wiki.<br />Qt-Complex is a code package that can be added to any Qt-Quick project - also existing - giving the possibility to manage complex components like Ovi maps navigation, animated toolbars, grouped switches etc. Following the QML philosophy Qt-Complex is hyerarchical so you find simple elements (button switch, button, standard toolbar, …) and complex elements that reuses the same base objects.


== Other pages in this wiki ==
== Other pages in this wiki ==
Line 15: Line 15:
== Adding the framework to your project ==
== Adding the framework to your project ==


Qt-Complex is a opensource package that you should include in your project tree as an independent set of QML pages and other stuff. The Qt-Quick project can be cloned from the &quot;Qt-Complex repository&amp;quot;:https://projects.developer.nokia.com/Qt_Complex/browser but the simple way is downloading the bare bone framework from &quot;'''here'''&quot;:https://projects.developer.nokia.com/Qt_Complex/downloads/4<br />Supposing that your QML components are in the folder ''/Development_Folder/MyProject/qml/MyProject'' copy the Qt-Complex main folder in your QML project root. If your project has also a ''/images'' folder and a ''/components'' folder the result should be the following:
Qt-Complex is a opensource package that you should include in your project tree as an independent set of QML pages and other stuff. The Qt-Quick project can be cloned from the "Qt-Complex repository":https://projects.developer.nokia.com/Qt_Complex/browser but the simple way is downloading the bare bone framework from "'''here'''":https://projects.developer.nokia.com/Qt_Complex/downloads/4<br />Supposing that your QML components are in the folder ''/Development_Folder/MyProject/qml/MyProject'' copy the Qt-Complex main folder in your QML project root. If your project has also a ''/images'' folder and a ''/components'' folder the result should be the following:


…/qml/MyProject/*.qml<br />…/qml/MyProject/images/[graphic stuff]<br />…/qml/MyProject/components/*.qml<br />…/qml/MyProject/Qt-Complex/*.qml<br />…/qml/MyProject/Qt-Complex/images<br />…/qml/MyProject/Qt-Complex/themes/default
…/qml/MyProject/*.qml<br />…/qml/MyProject/images/[graphic stuff]<br />…/qml/MyProject/components/*.qml<br />…/qml/MyProject/Qt-Complex/*.qml<br />…/qml/MyProject/Qt-Complex/images<br />…/qml/MyProject/Qt-Complex/themes/default
Line 21: Line 21:
=== Prerequisites ===
=== Prerequisites ===


Qt_Complex can be installed in Qt-Quick project created with Qt SDK 4.7.3 with Qt-Quick components for Symbian and Meego. For more information and installation details read the lab article &quot;Qt Quick components for Symbian and MeeGo 1.2 Harmattan&amp;quot;:http://labs.qt.nokia.com/2011/07/06/ready-made-ui-building-blocks-at-your-service-qt-quick-components-for-symbian-and-meego-1-2-harmattan/
Qt_Complex can be installed in Qt-Quick project created with Qt SDK 4.7.3 with Qt-Quick components for Symbian and Meego. For more information and installation details read the lab article "Qt Quick components for Symbian and MeeGo 1.2 Harmattan":http://labs.qt.nokia.com/2011/07/06/ready-made-ui-building-blocks-at-your-service-qt-quick-components-for-symbian-and-meego-1-2-harmattan/


To manage the Qt Quick components in your document sources you need to import the component itself (after the installation in you Qt Creator environment). It is needed to manage two different imports if you are developing applications for Harmattan Meego 1.2 or Symbian platofrms due to a known bug as you can find in this forum post: http://developer.qt.nokia.com/forums/viewthread/7971
To manage the Qt Quick components in your document sources you need to import the component itself (after the installation in you Qt Creator environment). It is needed to manage two different imports if you are developing applications for Harmattan Meego 1.2 or Symbian platofrms due to a known bug as you can find in this forum post: http://developer.qt.nokia.com/forums/viewthread/7971
Line 51: Line 51:
<code>// Main.qml
<code>// Main.qml


import QtQuick 1.0<br />import &quot;Qt-Complex&amp;quot; as Framework
import QtQuick 1.0<br />import "Qt-Complex" as Framework


Item {<br /> id: screen</code>
Item {<br /> id: screen</code>
Line 61: Line 61:
<code> // Map view object with navigaton controls<br /> Item {<br /> id: viewmap<br /> width: screen.width;<br /> height: screen.height - basebuttons.height - appTopBanner.height
<code> // Map view object with navigaton controls<br /> Item {<br /> id: viewmap<br /> width: screen.width;<br /> height: screen.height - basebuttons.height - appTopBanner.height


// Framework Map starts here<br /> Framework.MapLoader {<br /> id: viewmapLoader<br /> width: viewmap.width; height: viewmap.height;<br /> theme: &quot;default&amp;quot;; obj: &quot;MapView&amp;quot;<br /> }<br /> // Framework Map ends here
// Framework Map starts here<br /> Framework.MapLoader {<br /> id: viewmapLoader<br /> width: viewmap.width; height: viewmap.height;<br /> theme: "default"; obj: "MapView"<br /> }<br /> // Framework Map ends here


}</code>
}</code>
Line 67: Line 67:
=== Managing components: the loader ===
=== Managing components: the loader ===


One of the most important features of the Qt-Complex framework is that its components can be integrated and managed directly from your sources. The simple inclusion of the component as shown in the Map view example above is only to give you an idea of what can be done.<br />The framework has a set of predefined components i.e. ''Button, ButtonIcon, ButtonToolbar, MapView, Switch, Toolbar'' etc. For a complete list and description of the framework components read the &quot;'''component list'''&quot;:https://projects.developer.nokia.com/Qt_Complex/wiki/FrameworkComponents in the project wiki.<br />All the objects are built to be parametric and device independent. But it is not all: you don't need to instantiate the components in your QML sources because you use the '''Loader'''. This is a component that can be configured through its properties: the same loader is used to manage all the framework components.
One of the most important features of the Qt-Complex framework is that its components can be integrated and managed directly from your sources. The simple inclusion of the component as shown in the Map view example above is only to give you an idea of what can be done.<br />The framework has a set of predefined components i.e. ''Button, ButtonIcon, ButtonToolbar, MapView, Switch, Toolbar'' etc. For a complete list and description of the framework components read the "'''component list'''":https://projects.developer.nokia.com/Qt_Complex/wiki/FrameworkComponents in the project wiki.<br />All the objects are built to be parametric and device independent. But it is not all: you don't need to instantiate the components in your QML sources because you use the '''Loader'''. This is a component that can be configured through its properties: the same loader is used to manage all the framework components.


Using the loader instead of the component itself has several advantages:
Using the loader instead of the component itself has several advantages:
Line 79: Line 79:
Example1:
Example1:


<code> Framework.Loader {<br /> id: ex1<br /> width: parent.width; height: parent.height<br /> theme: &quot;MyTheme&amp;quot;; obj: &quot;ButtonIcon&amp;quot;; obj_string: &quot;Text will be here&amp;quot;<br /> obj_icon: fwProperties.btnBack<br /> onClicked: { manageEvent(); }<br /> }</code>
<code> Framework.Loader {<br /> id: ex1<br /> width: parent.width; height: parent.height<br /> theme: "MyTheme"; obj: "ButtonIcon"; obj_string: "Text will be here"<br /> obj_icon: fwProperties.btnBack<br /> onClicked: { manageEvent(); }<br /> }</code>


Example2:
Example2:


<code> Framework.Loader {<br /> id: ex2<br /> width: parent.width; height: parent.height<br /> theme: &quot;MyTheme&amp;quot;; obj: &quot;Button&amp;quot;; obj_string: &quot;Text will be here&amp;quot;<br /> onClicked: { manageEvent(); }<br /> }</code>
<code> Framework.Loader {<br /> id: ex2<br /> width: parent.width; height: parent.height<br /> theme: "MyTheme"; obj: "Button"; obj_string: "Text will be here"<br /> onClicked: { manageEvent(); }<br /> }</code>


The two examples below shows how to call the loader managing two different components. For more information on loader usage and properties setting please read &quot;'''Loader Usage'''&quot;:https://projects.developer.nokia.com/Qt_Complex/wiki/LoaderUsage at the project wiki.
The two examples below shows how to call the loader managing two different components. For more information on loader usage and properties setting please read "'''Loader Usage'''":https://projects.developer.nokia.com/Qt_Complex/wiki/LoaderUsage at the project wiki.


=== Loader parametrization ===
=== Loader parametrization ===
Line 94: Line 94:


// Set the object to show in the UI based on a program parameter<br /> function getObjectName() {<br /> if(decisionFlag  1)
// Set the object to show in the UI based on a program parameter<br /> function getObjectName() {<br /> if(decisionFlag  1)
             return &amp;quot;ButtonIcon&amp;quot;;
             return "ButtonIcon";
         else
         else
             if(decisionFlag  2)<br /> return &quot;Button&amp;quot;;<br /> return &quot;&quot;;<br />}
             if(decisionFlag  2)<br /> return "Button";<br /> return "";<br />}


[… your soruce code …]
[… your soruce code …]


// The loader shows the object returned by the function<br /> Framework.Loader {<br /> id: myloader<br /> width: Jmain.getBaseCenterBtnWidth(); height: parent.height<br /> theme: &quot;MyTheme&amp;quot;; obj: getObjectName(); obj_string: &quot;Object text&amp;quot;<br /> onClicked: { manageEvent(); }<br /> }
// The loader shows the object returned by the function<br /> Framework.Loader {<br /> id: myloader<br /> width: Jmain.getBaseCenterBtnWidth(); height: parent.height<br /> theme: "MyTheme"; obj: getObjectName(); obj_string: "Object text"<br /> onClicked: { manageEvent(); }<br /> }


[… your source code …']<br />}</code>
[… your source code …']<br />}</code>
Line 106: Line 106:
In this code snippet it is not sure what is the object shown by ''myLoader'' at this point: it depends by the value of the ''decisionFlag''.
In this code snippet it is not sure what is the object shown by ''myLoader'' at this point: it depends by the value of the ''decisionFlag''.


The framework Loader component is the replacing of the ''QML Loader'' with some extending funcitonalities: its custom properties. The most interesting property of the QML Loader is that to destroy a loaded object it is sufficient to set the ''Loader.obj'' property to an empty string. Qt-Complex Loader uses this property to destroy the loaded components but instantiating a Loader with the Loader.obj string set to '''&quot;&quot;''' (empty string) no object is loaded so nothing is shown.
The framework Loader component is the replacing of the ''QML Loader'' with some extending funcitonalities: its custom properties. The most interesting property of the QML Loader is that to destroy a loaded object it is sufficient to set the ''Loader.obj'' property to an empty string. Qt-Complex Loader uses this property to destroy the loaded components but instantiating a Loader with the Loader.obj string set to '''""''' (empty string) no object is loaded so nothing is shown.


It is also possible to enable the auto-destruction of the loader setting the ''destroyAfter'' flag to true. When this flag is set when the loaded object fires a signal to the calling program the loader is immediately destroyed i.e. in cases where a object should show a condition that occasionally occours in the program flow and can happen only once.
It is also possible to enable the auto-destruction of the loader setting the ''destroyAfter'' flag to true. When this flag is set when the loaded object fires a signal to the calling program the loader is immediately destroyed i.e. in cases where a object should show a condition that occasionally occours in the program flow and can happen only once.
Line 114: Line 114:
Qt-Complex supports multiple themes at the same time. The simplest application of theming representing this feature is the usage of the ''theme'' property of the Loaders. To add a personalized set of graphic elements you need to create your own theme folder under ''…/Qt-Complex/themes'' with the design you need. Files should have the same name you see in the default theme folder.<br />But the most interesting property of the theme management in Qt-Complex is that you can create your own loadable components that should be used only with certain themes and not with others.
Qt-Complex supports multiple themes at the same time. The simplest application of theming representing this feature is the usage of the ''theme'' property of the Loaders. To add a personalized set of graphic elements you need to create your own theme folder under ''…/Qt-Complex/themes'' with the design you need. Files should have the same name you see in the default theme folder.<br />But the most interesting property of the theme management in Qt-Complex is that you can create your own loadable components that should be used only with certain themes and not with others.


Then you can also add to your theme folder - that is '''not''' a graphic repository ony - also theme-dependant personalized components or script functions. To know more about theme management in Qt-Complex you can read the &quot;'''themes How-to'''&quot;:https://projects.developer.nokia.com/Qt_Complex/wiki/CreatingTheme in the wiki project page.
Then you can also add to your theme folder - that is '''not''' a graphic repository ony - also theme-dependant personalized components or script functions. To know more about theme management in Qt-Complex you can read the "'''themes How-to'''":https://projects.developer.nokia.com/Qt_Complex/wiki/CreatingTheme in the wiki project page.


=== The 'theme' custom property ===
=== The 'theme' custom property ===


Calling the loader from your application there are two mandatory custom properties that should be set:<br /><code><br />theme: &quot;theme_name&amp;quot;<br />obj: &quot;object_to_load&amp;quot;<br /></code><br />The ''theme'' property is the theme name: this is the subfolder of ''Qt-Complex/themes/'' where you should put your theme images and custom QML documents. There is a workaround due to a behavior actually unsolved described here http://developer.qt.nokia.com/forums/viewthread/8110
Calling the loader from your application there are two mandatory custom properties that should be set:<br /><code><br />theme: "theme_name"<br />obj: "object_to_load"<br /></code><br />The ''theme'' property is the theme name: this is the subfolder of ''Qt-Complex/themes/'' where you should put your theme images and custom QML documents. There is a workaround due to a behavior actually unsolved described here http://developer.qt.nokia.com/forums/viewthread/8110

Revision as of 06:33, 25 February 2015

[toc align_right="yes" depth="3"]

Qt-Complex (1.1.0 Harmattan release)

Qt-Complex in action

This article is intended as a quick user guide for the Qt-Complex framework installation and usage, 1.1.0 Harmattan release. A complete documentation can be found on the "project wiki pages":https://projects.developer.nokia.com/Qt_Complex/wiki.
Qt-Complex is a code package that can be added to any Qt-Quick project - also existing - giving the possibility to manage complex components like Ovi maps navigation, animated toolbars, grouped switches etc. Following the QML philosophy Qt-Complex is hyerarchical so you find simple elements (button switch, button, standard toolbar, …) and complex elements that reuses the same base objects.

Other pages in this wiki

Adding the framework to your project

Qt-Complex is a opensource package that you should include in your project tree as an independent set of QML pages and other stuff. The Qt-Quick project can be cloned from the "Qt-Complex repository":https://projects.developer.nokia.com/Qt_Complex/browser but the simple way is downloading the bare bone framework from "here":https://projects.developer.nokia.com/Qt_Complex/downloads/4
Supposing that your QML components are in the folder /Development_Folder/MyProject/qml/MyProject copy the Qt-Complex main folder in your QML project root. If your project has also a /images folder and a /components folder the result should be the following:

…/qml/MyProject/*.qml
…/qml/MyProject/images/[graphic stuff]
…/qml/MyProject/components/*.qml
…/qml/MyProject/Qt-Complex/*.qml
…/qml/MyProject/Qt-Complex/images
…/qml/MyProject/Qt-Complex/themes/default

Prerequisites

Qt_Complex can be installed in Qt-Quick project created with Qt SDK 4.7.3 with Qt-Quick components for Symbian and Meego. For more information and installation details read the lab article "Qt Quick components for Symbian and MeeGo 1.2 Harmattan":http://labs.qt.nokia.com/2011/07/06/ready-made-ui-building-blocks-at-your-service-qt-quick-components-for-symbian-and-meego-1-2-harmattan/

To manage the Qt Quick components in your document sources you need to import the component itself (after the installation in you Qt Creator environment). It is needed to manage two different imports if you are developing applications for Harmattan Meego 1.2 or Symbian platofrms due to a known bug as you can find in this forum post: http://developer.qt.nokia.com/forums/viewthread/7971

Import for Harmattan

import com.nokia.symbian 1.0<code>

==== Import for Symbian (and desktop) ====

import com.nokia.symbian 1.0

Framework compatibility

Qt-Complex is platform independent thus its components works on desktop, Symbian S60 3rd edition and 5th edition, Symbian^1 and Symbian^3 and on the Harmattan platforms. The framework components was tested on the following physical devices:

  • Nokia E7-00
  • Nokia N8
  • Nokia E90 (experimental only)
  • Nokia N950 (full working integrating page stack navigation)
  • Macbook with Snow Leopard
  • Windows 7 and Windows Xp SP3
  • Ubuntu 10.4 Lucid

Importing Qt-Complex in your project

At this point to use the framework components in your project you should declare an import on top of your QML sources. Following the folder organization as described above, the result should something like the following example:

// Main.qml

import QtQuick 1.0<br />import "Qt-Complex" as Framework

Item {<br /> id: screen

Using the framework components in your QML sources

Adding the import statement in all the QML sources where you plan to use the framework it is simple also if the project already exist.

 // Map view object with navigaton controls<br /> Item {<br /> id: viewmap<br /> width: screen.width;<br /> height: screen.height - basebuttons.height - appTopBanner.height

// Framework Map starts here<br /> Framework.MapLoader {<br /> id: viewmapLoader<br /> width: viewmap.width; height: viewmap.height;<br /> theme: "default"; obj: "MapView"<br /> }<br /> // Framework Map ends here

}

Managing components: the loader

One of the most important features of the Qt-Complex framework is that its components can be integrated and managed directly from your sources. The simple inclusion of the component as shown in the Map view example above is only to give you an idea of what can be done.
The framework has a set of predefined components i.e. Button, ButtonIcon, ButtonToolbar, MapView, Switch, Toolbar etc. For a complete list and description of the framework components read the "component list":https://projects.developer.nokia.com/Qt_Complex/wiki/FrameworkComponents in the project wiki.
All the objects are built to be parametric and device independent. But it is not all: you don't need to instantiate the components in your QML sources because you use the Loader. This is a component that can be configured through its properties: the same loader is used to manage all the framework components.

Using the loader instead of the component itself has several advantages:

  • Components uses memory and device resources only when they are physically loaded.
  • Components no more used in the program can be unloaded with the Destroy() method
  • The components names are string and can be built with functions.
  • Complex objects can instantiate the loader for a variable number of times.
  • The loader can be used to dynamically manage your components.

Example1:

 Framework.Loader {<br /> id: ex1<br /> width: parent.width; height: parent.height<br /> theme: "MyTheme"; obj: "ButtonIcon"; obj_string: "Text will be here"<br /> obj_icon: fwProperties.btnBack<br /> onClicked: { manageEvent(); }<br /> }

Example2:

 Framework.Loader {<br /> id: ex2<br /> width: parent.width; height: parent.height<br /> theme: "MyTheme"; obj: "Button"; obj_string: "Text will be here"<br /> onClicked: { manageEvent(); }<br /> }

The two examples below shows how to call the loader managing two different components. For more information on loader usage and properties setting please read "Loader Usage":https://projects.developer.nokia.com/Qt_Complex/wiki/LoaderUsage at the project wiki.

Loader parametrization

As a matter of fact the loader is full transparent to the program logic: it is an intermediate element holding the instance name to manage all the signals of the object that it is pointing to. In the following example you can see how the loader can be parametrized calling one component instead of another or nothing at all.

// Start of MyDocument.qml<br />Instance {<br /> id: myInstance

// Set the object to show in the UI based on a program parameter<br /> function getObjectName() {<br /> if(decisionFlag  1)
            return "ButtonIcon";
        else
            if(decisionFlag  2)<br /> return "Button";<br /> return "";<br />}

[ your soruce code ]

// The loader shows the object returned by the function<br /> Framework.Loader {<br /> id: myloader<br /> width: Jmain.getBaseCenterBtnWidth(); height: parent.height<br /> theme: "MyTheme"; obj: getObjectName(); obj_string: "Object text"<br /> onClicked: { manageEvent(); }<br /> }

[ your source code …']<br />}

In this code snippet it is not sure what is the object shown by myLoader at this point: it depends by the value of the decisionFlag.

The framework Loader component is the replacing of the QML Loader with some extending funcitonalities: its custom properties. The most interesting property of the QML Loader is that to destroy a loaded object it is sufficient to set the Loader.obj property to an empty string. Qt-Complex Loader uses this property to destroy the loaded components but instantiating a Loader with the Loader.obj string set to "" (empty string) no object is loaded so nothing is shown.

It is also possible to enable the auto-destruction of the loader setting the destroyAfter flag to true. When this flag is set when the loaded object fires a signal to the calling program the loader is immediately destroyed i.e. in cases where a object should show a condition that occasionally occours in the program flow and can happen only once.

Theming

Qt-Complex supports multiple themes at the same time. The simplest application of theming representing this feature is the usage of the theme property of the Loaders. To add a personalized set of graphic elements you need to create your own theme folder under …/Qt-Complex/themes with the design you need. Files should have the same name you see in the default theme folder.
But the most interesting property of the theme management in Qt-Complex is that you can create your own loadable components that should be used only with certain themes and not with others.

Then you can also add to your theme folder - that is not a graphic repository ony - also theme-dependant personalized components or script functions. To know more about theme management in Qt-Complex you can read the "themes How-to":https://projects.developer.nokia.com/Qt_Complex/wiki/CreatingTheme in the wiki project page.

The 'theme' custom property

Calling the loader from your application there are two mandatory custom properties that should be set:

<br />theme: "theme_name"<br />obj: "object_to_load"<br />


The theme property is the theme name: this is the subfolder of Qt-Complex/themes/ where you should put your theme images and custom QML documents. There is a workaround due to a behavior actually unsolved described here http://developer.qt.nokia.com/forums/viewthread/8110

This category currently contains no pages or media.