QtComplexTestApplication: Difference between revisions

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


(return to the main [http://developer.qt.nokia.com/wiki/category:Tools::QtComplex Qt-Complex wiki page] ''[developer.qt.nokia.com]'' or go to the [https://projects.developer.nokia.com/Qt_Complex main project page] ''[projects.developer.nokia.com]'')
= Qt-Complex test application dissection =


For a detailed documentation on the framework components, usage and sample code go to the project wiki [https://projects.developer.nokia.com/Qt_Complex/wiki/FrameworkComponents Framework Components] ''[projects.developer.nokia.com]''
(return to the main "Qt-Complex wiki page":http://developer.qt.nokia.com/wiki/category:Tools::QtComplex or go to the "main project page":https://projects.developer.nokia.com/Qt_Complex)


Qt-Complex repository and [https://projects.developer.nokia.com/Qt_Complex/downloads/4 downoadable package] ''[projects.developer.nokia.com]'' is provided with a '''test application''' aiming to give and essential example of how the framework works, how it can be integrated in your project and how it can co-exist with a typical stacked page navigation.
For a detailed documentation on the framework components, usage and sample code go to the project wiki "Framework Components":https://projects.developer.nokia.com/Qt_Complex/wiki/FrameworkComponents


==Test application modules==
Qt-Complex repository and "downoadable package":https://projects.developer.nokia.com/Qt_Complex/downloads/4 is provided with a '''test application''' aiming to give and essential example of how the framework works, how it can be integrated in your project and how it can co-exist with a typical stacked page navigation.
 
== Test application modules ==


The test application is built with the following modules plust the main.cpp source:
The test application is built with the following modules plust the main.cpp source:
Line 16: Line 18:
* '''SamplePage.qml''' another stacked page showing a demo form with some framework components.
* '''SamplePage.qml''' another stacked page showing a demo form with some framework components.


==Top imports==
== Top imports ==


On top of every module there is the import group for Qt Quick components and Qt-Complex framework
On top of every module there is the import group for Qt Quick components and Qt-Complex framework
<code><br /> import QtQuick 1.1<br /> import com.meego 1.0<br /> import &quot;QtComplex&amp;quot; as Framework<br /> import &quot;QtComplex/Theme.js&amp;quot; as Theme<br /> import &quot;QtComplex/Geometry.js&amp;quot; as Geometry<br /> import &quot;QtComplex/TestApplication.js&amp;quot; as Test<br /></code>


As you can see '''TestApplication.js''' is imported as part of the application. This javascript defines all the methods to manage some properties and signals that are part of the test applicaiton, not of the framework itself.
As you can see '''TestApplication.js''' is imported as part of the application. This javascript defines all the methods to manage some properties and signals that are part of the test applicaiton, not of the framework itself.


===The web pages===
=== The web pages ===


The ''MainUrl.qml, WikiPage.qml'' and ''SourcePage.qml'' sources showing the embedded browser also import the '''WebKit 1.0''' module.
The ''MainUrl.qml, WikiPage.qml'' and ''SourcePage.qml'' sources showing the embedded browser also import the '''WebKit 1.0''' module.


==main.qml==
== main.qml ==


The main.qml instantiates the global elements and the ''PageStackWindow''. The navigation mechanism of the application is based on the page stack push/pop. The application starts from main.qml launching the ''MainPage.qml'' then the user can navigate to the other pages from the toolbar menu.
The main.qml instantiates the global elements and the ''PageStackWindow''. The navigation mechanism of the application is based on the page stack push/pop. The application starts from main.qml launching the ''MainPage.qml'' then the user can navigate to the other pages from the toolbar menu.


As the '''main.qml''' is the ''PageStackWindow'' the methods and instances defined here will be managed by the other loaded pages.<br /> main.qml defines the toolbar and the menu, the initial page MainPage.qml and the simple '''openFile()''' method.
As the '''main.qml''' is the ''PageStackWindow'' the methods and instances defined here will be managed by the other loaded pages.<br />main.qml defines the toolbar and the menu, the initial page - MainPage.qml - and the simple '''openFile&amp;amp;#40;&amp;#41;''' method.
 
<code><br /> // Open a page and push it in the stack<br /> function openFile&amp;amp;#40;file&amp;amp;#41; {<br /> // Create the Qt component based on the file/qml page to load.<br /> var component = Qt.createComponent(file)<br /> // If the page is ready to be managed it is pushed onto the stack<br /> if (component.status == Component.Ready)<br /> pageStack.push(component);<br /> else<br /> console.log(&quot;Error loading: &quot; + component.errorString());<br /> }<br /></code>


As main.qml defines the ''ToolBarLayout'' it is possible to include other Qt-Complex elements that should always be present. This document is on top of the tree architecture so the components defined here are accessible and visible on all the application pages.
As main.qml defines the ''ToolBarLayout'' it is possible to include other Qt-Complex elements that should always be present. This document is on top of the tree architecture so the components defined here are accessible and visible on all the application pages.


==TestApplication architecture==
== TestApplication architecture ==


The architecture of the test application shows the two different navigation methods, tests the Mobility libraries and location component and shows some of the Qt-Complex components in action.
The architecture of the test application shows the two different navigation methods, tests the Mobility libraries and location component and shows some of the Qt-Complex components in action.


===Entry point===
=== Entry point ===


The main.qml ''PageStackWindow'' decides what is the first loaded page (MainPage.qml). Instantiates the ''ToolBarLayout'' and ''menu''. You can also try changing the first page using the SamplePage.qml instead of mainPage.qml changing the main.qml source as shown in the following code snippet:
The main.qml ''PageStackWindow'' decides what is the first loaded page (MainPage.qml). Instantiates the ''ToolBarLayout'' and ''menu''. You can also try changing the first page using the SamplePage.qml instead of mainPage.qml changing the main.qml source as shown in the following code snippet:


===The other <span class="caps">QML</span> documents===
<code><br /> PageStackWindow {<br /> id: appWindow<br /> initialPage: SamplePage
 
MainPage{id: mainPage}
 
[… the main.qml code …]
 
MenuItem {<br /> text: &quot;Sample page&amp;quot;<br /> onClicked: openFile&amp;amp;#40;&quot;MainPage.qml&amp;quot;&amp;#41;;<br /> }
 
[… the main.qml code …]<br /></code>
 
=== The other QML documents ===


* '''MainPage.qml''' Shows the splash page than opens the Qt-Complex toolbar alternatively showing a home, a Ovi map area with the navigation buttons, the info screen.
* '''MainPage.qml''' Shows the splash page than opens the Qt-Complex toolbar alternatively showing a home, a Ovi map area with the navigation buttons, the info screen.
Line 48: Line 64:
* '''Menu''' Implements three ''embedded web'' pages showing repectively:
* '''Menu''' Implements three ''embedded web'' pages showing repectively:


* Access to the '''main project page''' (''MainUrl.qml'')
'''''' Access to the '''main project page''' (''MainUrl.qml'')<br />'''''' Access to the '''wiki documentaton pages''' (''WikiPage.qml'')<br />'''''' Access to the '''framework sources''' (''SourcePage.qml'')<br />'''''' A '''simple form''' with Qt-Complex components (''SamplePage.qml'')
* Access to the '''wiki documentaton pages''' (''WikiPage.qml'')
* Access to the '''framework sources''' (''SourcePage.qml'')
* A '''simple form''' with Qt-Complex components (''SamplePage.qml'')

Revision as of 11:41, 24 February 2015

[toc align_right="yes&quot; depth="3&quot;]

Qt-Complex test application dissection

(return to the main "Qt-Complex wiki page&quot;:http://developer.qt.nokia.com/wiki/category:Tools::QtComplex or go to the "main project page&quot;:https://projects.developer.nokia.com/Qt_Complex)

For a detailed documentation on the framework components, usage and sample code go to the project wiki "Framework Components&quot;:https://projects.developer.nokia.com/Qt_Complex/wiki/FrameworkComponents

Qt-Complex repository and "downoadable package&quot;:https://projects.developer.nokia.com/Qt_Complex/downloads/4 is provided with a test application aiming to give and essential example of how the framework works, how it can be integrated in your project and how it can co-exist with a typical stacked page navigation.

Test application modules

The test application is built with the following modules plust the main.cpp source:

  • main.qml file that implement the PageStackWindow component with the common toolbar and a custom menu.
  • MainPage.qml file that demonstrate the use of multiple framework components managed with the loader all in one document.
  • MainUrl.qml, WikiPage.qml and SourcePage.qml These are three pages that differs only for the opened url. Was used three different pages to demonstrate te page stack navigation based on the common tools menu.
  • SamplePage.qml another stacked page showing a demo form with some framework components.

Top imports

On top of every module there is the import group for Qt Quick components and Qt-Complex framework

<br /> import QtQuick 1.1<br /> import com.meego 1.0<br /> import &quot;QtComplex&amp;quot; as Framework<br /> import &quot;QtComplex/Theme.js&amp;quot; as Theme<br /> import &quot;QtComplex/Geometry.js&amp;quot; as Geometry<br /> import &quot;QtComplex/TestApplication.js&amp;quot; as Test<br />

As you can see TestApplication.js is imported as part of the application. This javascript defines all the methods to manage some properties and signals that are part of the test applicaiton, not of the framework itself.

The web pages

The MainUrl.qml, WikiPage.qml and SourcePage.qml sources showing the embedded browser also import the WebKit 1.0 module.

main.qml

The main.qml instantiates the global elements and the PageStackWindow. The navigation mechanism of the application is based on the page stack push/pop. The application starts from main.qml launching the MainPage.qml then the user can navigate to the other pages from the toolbar menu.

As the main.qml is the PageStackWindow the methods and instances defined here will be managed by the other loaded pages.
main.qml defines the toolbar and the menu, the initial page - MainPage.qml - and the simple openFile&amp;#40;&#41; method.

<br /> // Open a page and push it in the stack<br /> function openFile&amp;amp;#40;file&amp;amp;#41; {<br /> // Create the Qt component based on the file/qml page to load.<br /> var component = Qt.createComponent(file)<br /> // If the page is ready to be managed it is pushed onto the stack<br /> if (component.status == Component.Ready)<br /> pageStack.push(component);<br /> else<br /> console.log(&quot;Error loading: &quot; + component.errorString());<br /> }<br />

As main.qml defines the ToolBarLayout it is possible to include other Qt-Complex elements that should always be present. This document is on top of the tree architecture so the components defined here are accessible and visible on all the application pages.

TestApplication architecture

The architecture of the test application shows the two different navigation methods, tests the Mobility libraries and location component and shows some of the Qt-Complex components in action.

Entry point

The main.qml PageStackWindow decides what is the first loaded page (MainPage.qml). Instantiates the ToolBarLayout and menu. You can also try changing the first page using the SamplePage.qml instead of mainPage.qml changing the main.qml source as shown in the following code snippet:

<br /> PageStackWindow {<br /> id: appWindow<br /> initialPage: SamplePage

MainPage{id: mainPage}

[ the main.qml code ]

MenuItem {<br /> text: &quot;Sample page&amp;quot;<br /> onClicked: openFile&amp;amp;#40;&quot;MainPage.qml&amp;quot;&amp;#41;;<br /> }

[ the main.qml code ]<br />

The other QML documents

  • MainPage.qml Shows the splash page than opens the Qt-Complex toolbar alternatively showing a home, a Ovi map area with the navigation buttons, the info screen.
  • Toolbar Implements the Back button to move across the pages using the page stack and the menu to load the other pages
  • Menu Implements three embedded web pages showing repectively:

' Access to the main project page (MainUrl.qml)
'
Access to the wiki documentaton pages (WikiPage.qml)
' Access to the framework sources (SourcePage.qml)
'
A simple form with Qt-Complex components (SamplePage.qml)