Building apps for the Ubuntu Phone
|
Hello, World!
After completing the steps successfully, you will end up in a document that already contains code. On 12.10, using Tools | External | Qt Quick | Preview (qmlscene) doesn't let you run the code, because it is a bit outdated. An online working code example from David Planella [4] appears in Listing 1. A simple copy-and-paste is enough to add the code and, using the aforementioned steps, you'll be able to see your application.
Listing 1
"CurrencyConverter"
01 import QtQuick 2.0 02 import Ubuntu.Components 0.1 03 04 Rectangle { 05 id: root 06 width: units.gu(60) 07 height: units.gu(80) 08 color: "lightgray" 09 10 property real margins: units.gu(2) 11 property real buttonWidth: units.gu(9) 12 13 Label { 14 id: title 15 ItemStyle.class: "title" 16 text: i18n.tr("Currency Converter") 17 height: contentHeight + root.margins 18 anchors { 19 left: parent.left 20 right: parent.right 21 top: parent.top 22 } 23 } 24 }
On 13.04, however, if you visit Tools | External | Qt Quick | Qt quick 2 Preview (qmlscene) , you will immediately be able to run the placeholder program, and you will see a window like the one in Figure 1. Running the program shown in Listing 1 results in a window like the one in Figure 2.
Starting package
Now you can begin to work through some of the tutorials to understand QML better – practiced JavaScript users have a definite advantage. Planella's tutorial is a good start [4]; with a dearth of other tutorials, Planella points to the API for the currently available elements [5].
Qt5 developers also have other tutorials online that explain how to develop the QML graphical interface [6]. Because the SDK for 12.10 is a bit spotty, I recommend upgrading to the SDK offered in 13.04, which is much better and easier to set up. Interested developers can also register with the "Ubuntu for Phones" project [7].
Infos
- Apps for Ubuntu for Phones: http://www.ubuntu.com/devices/phone/app-ecosystem
- QML Toolkit for Ubuntu 12.04: http://askubuntu.com/questions/235440/how-do-i-install-the-qml-toolkit-on-12-04
- Setting up Bazaar version control: http://doc.bazaar.canonical.com/bzr.dev/en/user-guide/index.html
- Code examples for CurrencyConverter: http://developer.ubuntu.com/resources/app-developer-cookbook/mobile/currency-converter-phone-app/
- QML API: http://developer.ubuntu.com/api/ubuntu-12.10/qml/mobile/overview-ubuntu-sdk.html
- Qt Quick fundamentals: http://qt-project.org/doc/qt-5.0/qtdoc/qtexamplesandtutorials.html#qt-quick-essentials
- QML app developer website: http://developer.ubuntu.com/get-started/gomobile/
« Previous 1 2 Next »
Buy this article as PDF
Pages: 3
(incl. VAT)