QtComplexTestApplication: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
= | [toc align_right="yes" depth="3"] | ||
= Qt-Complex test application dissection = | |||
(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) | |||
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 "QtComplex&quot; as Framework<br /> import "QtComplex/Theme.js&quot; as Theme<br /> import "QtComplex/Geometry.js&quot; as Geometry<br /> import "QtComplex/TestApplication.js&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 | 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;#40;&#41;''' method. | ||
<code><br /> // Open a page and push it in the stack<br /> function openFile&amp;#40;file&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("Error loading: " + 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 | <code><br /> PageStackWindow {<br /> id: appWindow<br /> initialPage: SamplePage | ||
MainPage{id: mainPage} | |||
[… the main.qml code …] | |||
MenuItem {<br /> text: "Sample page&quot;<br /> onClicked: openFile&amp;#40;"MainPage.qml&quot;&#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'')<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'') | |||
Revision as of 11:41, 24 February 2015
[toc align_right="yes" depth="3"]
Qt-Complex test application dissection
(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)
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
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:
- 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 "QtComplex&quot; as Framework<br /> import "QtComplex/Theme.js&quot; as Theme<br /> import "QtComplex/Geometry.js&quot; as Geometry<br /> import "QtComplex/TestApplication.js&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&#40;) method.
<br /> // Open a page and push it in the stack<br /> function openFile&amp;#40;file&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("Error loading: " + 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: "Sample page&quot;<br /> onClicked: openFile&amp;#40;"MainPage.qml&quot;&#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)