Top Banner
Necessitas Qt on Android Johan Thelin Pelagicore
47

Necessitas - Qt on Android - from FSCONS 2011

Sep 08, 2014

Download

Sports

Johan Thelin

 
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Necessitas - Qt on Android - from FSCONS 2011

NecessitasQt on Android

Johan ThelinPelagicore

Page 2: Necessitas - Qt on Android - from FSCONS 2011

Biography

● Johan Thelin

● Worked with Qt for 10+ years● Foundations in Qt Development● Also worked embedded, embedded Linux, enterprise software, web

● Today – senior developer at Pelagicore

Page 3: Necessitas - Qt on Android - from FSCONS 2011

Pelagicore

● Open source based in-vehicle infotainment● Member of Linux Foundation● Ubuntu Core member● GENIVI member● Active within MeeGo, etc

● Uses Qt and QtQuick extensively● Also HTML5, JavaScript and Android

Page 4: Necessitas - Qt on Android - from FSCONS 2011

What is Qt

“Code less, create more, deploy everywhere”

● A great framework for creating applications● Truly cross-platform

● Desktop● Devices

● Licensed for everyone – GPL, LGPL or closed

Page 5: Necessitas - Qt on Android - from FSCONS 2011

Qt on Desktop

● X11● OS X● Windows

Page 6: Necessitas - Qt on Android - from FSCONS 2011

Qt on Devices

● Linux with X11● N900, N9

● Linux without X11● industrial, etc

● Symbian● WinCE

● more...

Page 7: Necessitas - Qt on Android - from FSCONS 2011

Who runs Qt?

● Trolltech ● Bought by Nokia● Nokia Qt Development Frameworks

● Digia develops and licenses Qt Commercial

● Qt is open source – www.qt-project.org● True open governance!

Page 8: Necessitas - Qt on Android - from FSCONS 2011

Qt on Devices

● More than the official ports● Android

● RIM Blackberry● WebOS● iOS● Kindle

● WP7 can support native code mid-2012 :-)

Page 9: Necessitas - Qt on Android - from FSCONS 2011

Qt on Devices

● More verticals● Set-top boxes● Industrial panels● Tablets

● Your car

Page 10: Necessitas - Qt on Android - from FSCONS 2011

Finding the Roots of Qt

Backends

Page 11: Necessitas - Qt on Android - from FSCONS 2011

Backends

● Backends for OS primitives● Atomic operations, files, etc

● Backends for graphics rendering● Soft, OpenGL, OpenGL ES, GDI, etc

● Backends for image handling● Backends for accessibility● Backends for ...

Page 12: Necessitas - Qt on Android - from FSCONS 2011

Why Backends

Portability!

Page 13: Necessitas - Qt on Android - from FSCONS 2011

Portability between Devices

● QPA – Qt Platform Architecture – or something● Formerly known as Lighthouse

● A backend for porting Qt to new platforms● Focused at minimal effort, but with possibilities

Page 14: Necessitas - Qt on Android - from FSCONS 2011

Qt on Android

● Based on Android SDK / NDK● QPA

● Necessitas - the actual Qt Port

● QtCreator (IDE) adaptations● The tooling

● Ministro● The deployment

Page 15: Necessitas - Qt on Android - from FSCONS 2011

Current Status

● Alpha 3 was just released● Most of Qt is ported● OpenGL rendering● WebKit

● Missing● Mobility (for many Android Versions)● Rewriting soft keyboard support● Android Style and Android Menus● Development support in non-Linux environments● Documentation

Page 16: Necessitas - Qt on Android - from FSCONS 2011

The Near Future

● Planning to release First Beta soon● Will give a stable API/ABI

“...meaning that an application which uses that version will run without *any* change, on any further releases! It also

means you can target a billion devices using Qt, much sooner than you expected :)”

Page 17: Necessitas - Qt on Android - from FSCONS 2011

Getting Started

● Installation party!● OpenJDK● ant 1.8+● The necessitas installer downloads and installs

– Android SDK + NDK– Platforms for the SDK, etc

● Setup QtCreator– Add path to ant

Page 18: Necessitas - Qt on Android - from FSCONS 2011

Installer

Page 19: Necessitas - Qt on Android - from FSCONS 2011

Demo Application

Page 20: Necessitas - Qt on Android - from FSCONS 2011

Demo Application

● Strip out some of the crud from the template source code – it refers to Symbian

Page 21: Necessitas - Qt on Android - from FSCONS 2011

Demo Application

void MainWindow::on_pushButton_clicked(){ static int v = 0; ui->listWidget->addItem( QString("Value%1").arg(v++));}

Page 22: Necessitas - Qt on Android - from FSCONS 2011

Demo Application

Page 23: Necessitas - Qt on Android - from FSCONS 2011

Demo Application

● From project directory

$ ls -l android/bin/total 1988-rw-rw-r-- 1 e8johan e8johan 179 2011-11-10 21:42 build.propdrwxrwxr-x 3 e8johan e8johan 4096 2011-11-10 21:42 classes-rw-rw-r-- 1 e8johan e8johan 33396 2011-11-10 21:42 classes.dex-rw-rw-r-- 1 e8johan e8johan 2251 2011-11-10 21:42 classes.dex.ddrwxrwxr-x 6 e8johan e8johan 4096 2011-11-10 21:42 res-rw-rw-r-- 1 e8johan e8johan 431594 2011-11-10 21:42 Widgetdemo.ap_-rw-rw-r-- 1 e8johan e8johan 2045 2011-11-10 21:42 Widgetdemo.ap_.d-rw-rw-r-- 1 e8johan e8johan 767735 2011-11-10 21:42 Widgetdemo-debug.apk-rw-rw-r-- 1 e8johan e8johan 767731 2011-11-10 21:42 Widgetdemo-debug-unaligned.apk-rw-rw-r-- 1 e8johan e8johan 305 2011-11-10 21:42 Widgetdemo-debug-unaligned.apk.d

Page 24: Necessitas - Qt on Android - from FSCONS 2011

First Run on Phone

● Installs Ministro – Installs Qt – Resumeshttps://market.android.com/details?id=eu.licentia.necessitas.ministro

Page 25: Necessitas - Qt on Android - from FSCONS 2011

Second Run

It simply works!

Page 26: Necessitas - Qt on Android - from FSCONS 2011

More on Ministro

● Qt libraries are shared among all Qt apps on the device

● From the beta release, the ABI is stable, i.e. Qt can be upgraded separately from apps

Page 27: Necessitas - Qt on Android - from FSCONS 2011

Configurability

● Android target SDK● API levels

● Application icon● Permissions

● What your app wants to be able to do

● Libraries● Which Qt modules are needed

● More...

Page 28: Necessitas - Qt on Android - from FSCONS 2011

Debugging

● Yes! :-)

● Android NDK comes with gdb● Works with QtCreator

● Requires some tweaking● Described in the Necessitas Wiki

Page 29: Necessitas - Qt on Android - from FSCONS 2011

Qt and Device UIs

Got to show you this!

Page 30: Necessitas - Qt on Android - from FSCONS 2011

User Interface Development

● Classic – standard widgets, etc● Rectangular areas● Non-overlapping● Clipping their children● Provides familiarity

● Device UIs● Blend with the device● Provide a brand feel● etc

Page 31: Necessitas - Qt on Android - from FSCONS 2011

Building Modern UIs

● No more widgets! ● Canvas / scene

● Timers everywhere● Multiple simultaneous transitions● Complex, interconnected state machines

● Pain! :-)

Page 32: Necessitas - Qt on Android - from FSCONS 2011

History of Qt and Modern UIs

● QCanvas● QGraphicsView● QTimeLine● QGraphicsItemAnimation● An animation framework● A state machine framework● The birth of QtQuick

Page 33: Necessitas - Qt on Android - from FSCONS 2011

QtQuick

● What is QtQuick?● A run-time for QML● Tooling

● What is QML● Declarative● JavaScript

Page 34: Necessitas - Qt on Android - from FSCONS 2011

QML

import QtQuick 1.0

Rectangle {

Rectangle {

MouseArea {

}

}

}

Page 35: Necessitas - Qt on Android - from FSCONS 2011

QML

Rectangle {

width: 500

height: 500

Rectangle {

Page 36: Necessitas - Qt on Android - from FSCONS 2011

QML

Rectangle {

Rectangle {

id: box

color: "red"

width: 100

height: 100

x: 200

Page 37: Necessitas - Qt on Android - from FSCONS 2011

QML

MouseArea {

anchors.fill: parent

onClicked: {

if(box.state=="up")

box.state="down";

else

box.state="up";

}

}

Page 38: Necessitas - Qt on Android - from FSCONS 2011

QML

Rectangle {

state: "up"

states: [

State {

name: "up"

PropertyChanges { target: box; y: 50 }

},

State {

name: "down"

PropertyChanges { target: box; y: 350 }

}

]

Page 39: Necessitas - Qt on Android - from FSCONS 2011

Demo

Page 40: Necessitas - Qt on Android - from FSCONS 2011

QML

Behavior on y {

PropertyAnimation {

duration: 1000

easing.type: Easing.OutBounce

}

}

Page 41: Necessitas - Qt on Android - from FSCONS 2011

Demo

Page 42: Necessitas - Qt on Android - from FSCONS 2011

Integrate with C++

● QObjects to QtQuickQObject *foo = …;

setProperty(“foo”, foo);

● C++ classes in QtQuickclass Foo : public QObject { … };

qmlRegisterType<Foo>("FooLib", 1, 0, "Foo");

Foo { property: value }

● QtMediaHub - http://gitorious.org/qtmediahub

Page 43: Necessitas - Qt on Android - from FSCONS 2011

QtMediaHub

Page 44: Necessitas - Qt on Android - from FSCONS 2011

Of course QtQuick works on Android too.With hardware accelerated graphics.

Page 45: Necessitas - Qt on Android - from FSCONS 2011

Qt 5

● A great opportunity to …● … get rid of API limitations● … split the repos into more independent parts● … take advantage of modern C++

● Widgets and QML are peers● More acceleration, shaders, etc – amazing

performance

Page 46: Necessitas - Qt on Android - from FSCONS 2011

A new Dawn

● Truly Open Source – a www.qt-project.org● Qt for Desktop

● Windows / X11 / OS X... more

● Qt for Devices● Symbian / Maemo / MeeGo / Android / Blackberry /

iOS / Kindle... more

Page 47: Necessitas - Qt on Android - from FSCONS 2011

Thank you!

[email protected]

We're hiring!http://pelagicore.com/career.html