Building apps for the Ubuntu Phone

Slashdot it! Delicious Share on Facebook Tweet! Digg!

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.

Figure 1: Use the QML Toolkit to create your first app for "Ubuntu for Phones."
Figure 2: CurrencyConverter gives you a taste of what you can do with QML.

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].

Buy this article as PDF

Express-Checkout as PDF

Pages: 3

Price $0.99
(incl. VAT)

Buy Ubuntu User

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content