Multi Platform Apps With QT
Multi Platform Apps With QT
Tuukka Ahoniemi
[email protected]
@tuukka_a
Santa Clara, CA
(soon back in Tampere, Finland)
1 © 2013 Digia
2
3
So…
4
N-Screen Problem
My Application
5
It’s Not Too Late to Change Your Career!
…Contact Your Local Military Draft Person Today!
6
Let’s Talk About Qt
7 © 2013 Digia
Contents
• Brief Introduction to Qt
• Traditional Qt/C++ with QWidgets
• Qt Quick and QML
• Qt 5 and Qt Roadmap
8 © 2013 Digia
Warning!
9
What is Qt?
Cross-
Integrated Cross-
Platform
Development Platform
Class Tools IDE
Library
Qt Application
Qt APIs
PC HW Mac HW PC HW Android HW
11
The Qt/Embedded Stack
Application
QtGui QtCore
Qt/Embedded
QPA
Wayland
Windows
linuxfb
EGL
QPA
X11
Plugins
HW PC HW PC HW
12
Supported Platforms
Windows Embedded
Windows (Standard/Compact 7)
Android (5.2, beta 5.1)
Win8 on ARM
Mac OS X INTEGRITY
(WinRT) (5.2?)
14
C++, traditional
C++, Cool UI
Qt/
C++
QML Qt/
C++
JS, Web
C++, customized
Java
Script
Qt/ Qt/
QML
C++ C++
QML
15
Small GUI Example with QWidgets 1/2
window
QWidget window;
QVBoxLayout* layout = new QVBoxLayout( &window );
QLCDNumber* lcd = new QLCDNumber( &window );
layout
QSlider* slider = new QSlider( Qt::Horizontal, &window );
layout->addWidget( lcd );
layout->addWidget( slider );
lcd slider
window.show();
return app.exec();
}
16
Small GUI Example with QWidgets 2/2 1. Slider is moved (to value 21)
window.show();
return app.exec();
}
17
Tools Integration
Qt Project App
qmake
GCC in
Makefile
[Linux compiler] Linux
[Linux/X11]
Qt/C++
Qt/C++
Qt/C++
code .pro
code
code
files
files
file
files
qmake
App
Makefile Cross compiler in
[Embedded Target HW
Linux]
qmake App
.gpj MULTI in
[INTEGRITY] Target HW
Other
IDE /
Code
Editor
Native tool chains
Qt Creator
© 2013 Digia Plc
Qt Application
PROJECT FORMS
DEFINITION
FILE mainwindow.ui
.pro
C++ CLASS
main.cpp mainwindow.h
mainwindow.cpp
Qt Application
.pro
C++ CLASS
main.cpp mainwindow.h
mainwindow.cpp
”Code behind”
Non-GUI Qt/C++ Support
• QtCore
• Data types, containers
• Threads, Processes, IPC
• File I/O
• String handling
• QtNetwork
• TCP/UDP, HTTP, FTP, SSL
• QtSql
• QtWebkit
• Etc.
21 © 2013 Digia
Qt Quick
Bridging the gap between designers and developers
22
22 © 2013 Digia
Qt UI Offering - Match the Purpose
Qt provides a set of UI tools and technologies for developers to choose from
C++, traditional
C++, Cool UI
Qt/
C++
QML Qt/
C++
JS, Web
C++, customized
Java
Script
Qt/ Qt/
QML
C++ C++
QML
23
24
What is Qt Quick?
QML
t
e
x
t
t
e
x
t
Declarative UI Design
t
e
x
t
Qt/C++
25
QML at a Glance
import QtQuick 2.1
Rectangle {
width: 200; height: 200
Text {
id: helloText
anchors.horizontalCenter: parent.horizontalCenter
font.pixelSize: parent.height / 10
font.bold: true
text: “MEET QML!"
}
Image {
id: helloImage
anchors.top: helloText.bottom
anchors.horizontalCenter: parent.horizontalCenter
source: "icons/qt_logo.png"
}
MouseArea { It’s simply all about elements,
anchors.fill: parent
onClicked: { properties and their values!
helloImage.visible = false;
helloText.text = "Bye-bye picture!";
}
}
}
26 © 2013 Digia
C++ Integration – Minimal Example
1: main.qml
Rectangle {
width: 200; height: 100 Write your QML UI
color: "lightblue"
Text {
anchors.centerIn: parent
font.pixelSize: 18
text: "I'm QML in a C++ app!"
}
}
QT += quick
2: minimalapp.pro
TARGET = minimalapp Link against the QtQuick module
TEMPLATE = app
SOURCES += main.cpp
#include <QtGui/QGuiApplication>
#include <QtQuick/QQuickView> 3: main.cpp
int main(int argc, char *argv[]) { Use the widget
QGuiApplication a(argc, argv);
QQuickView v(QUrl::fromLocalFile("main.qml"));
QQuickView to display
v.show(); your QML UI
return a.exec();
}
27 © 2013 Digia
A Bit More QML
Let’s look at some demos!
28
28 © 2013 Digia
Qt 5 and Qt Roadmap
29 © 2013 Digia
Re-Factored Internal
Architecture
• Qt Quick Controls
• Qt Quick just got serious on desktop as well
• New modules
• Qt Sensors, Qt Serial Port, X11 Extras, Wayland
iPad
BlackBerry Z10
Two different Android devices
with different OS versions
32 © 2013 Digia Plc
Qt Quick Controls and Layouts
33
Qt on New Mobile Platforms – Tech Previews
• Qt/Android (”beta”)
• Regular Qt applications running on regular Android OS (phones, tablets)
• Most of Qt functionality already there
• No Android functionality (native look-and-feel, back-button, in-app purchase)
• Qt Creator integration in good shape
• Deployment (to Google Play) not recommended even though might work
• Qt/iOS (”alpha”)
• Qt applications on iPhone or iPad
• Some Qt modules already there (Widgets, Qt Quick 1). No Qt Quick 2 or Webkit
• No Qt Creator integration, works in XCode
• Major internal changes taking place for 5.2 before deployment can be done
34
Multi-Screen Approaches with Qt
Where Are We Going with All This?
35
35 © 2013 Digia
Technical Enablers
QML
t
e
x
t
t
e
x
t
Declarative UI Design
t
e
x
t
Wide
+ platform
Qt/C++
support
Engine / Imperative Logic
Data Access
36
UIs Scale by Default
QML
t
e
x
t
t
e
x
t
t
e
x
t
Qt/C++
Engine /
Data Access
37
N-Screen Approaches – Different UI Designs
Mobile Layout Desktop Layout Tablet Layout Car Layout
t
e t t
t
x e e
e
t x x
x
t t
t
t
e t t
t
x e e
e
t x x
x
t t
t
t
e t t
t
x e e
e
t x x
x
t t
t
Qt/C++ t
e
x
t
Engine / t
e
Data Access x
t
Allows incremental
development, dynamic
replament of UIs
38
N-Screen Approaches – Mass-Customization
Generic Automotive Layout
t
e
x
t
Car MF 1 branded
t
e
x
t
t
e
x
t
t
e
x
t
t
e
x
t
Mass-customization
by Qt customer
Car MF 2 branded
t
e
x
t
Qt/C++
t
e
x
t
Engine /
Data Access t
e
x
t
39
Platform Specific Functionality
Mobile Layout Desktop Layout Tablet Layout
t
e t t
x e e
t x x
t t
t
e t t
x e e
t x x
t t
t
e t t
x e e
t x x
t t
Qt/C++
Engine / Android
Data Access functionality Hardware adaptation/optimization,
Bindings to native services,
Embedded Extra platform specific features
Linux on ARM
functionality
40
N-Screen Approaches – Partially Remote UI
Dynamic QML UI
t
e
x
t
t
e
x
t
t
e
x
t
Qt/C++
Engine /
Data Access
41
N-Screen Approaches – Remote UI
Remotely Loaded QML UI
t
e
x
t
t
e
x
t
t
e
x
t
Qt/C++
Engine /
Data Access
42
Structure of an N-screen App
Qt
43
Summary – Developer Story of Qt in 2013
• In Native We Trust
• The Power really lies in C++
44
Thank You!
[email protected]
www.qt.digia.com
© 2013 Digia