3. Qt in a Nutshell
in a Nutshell
Qt is a class library for platform
independent development of graphical
user interfaces based on C++.
The framework also includes XML,
The framework also includes XML,
databases, internationalization,
network, multithreading, 3D,
WebKit m ltimedia etc
WebKit, multimedia, etc.
3 Andreas Jakl, 2010
4. Short History
Short History of Qt
● 1991: Development started
− Cross platform GUI toolkit was needed
● 1994: Decided to go into business
− “Q” looked beautiful in Emacs font. “t” for toolkit Eirik Chambe‐ Haavard
− Company name: Quasar Technologies
Eng Nord
(later: Trolltech)
● 1995: First public release through newsgroups (Qt 0.90)
− Dual licensing: commercial & free for open source
● 2000: Qtopia – platform for mobile phones & PDAs
● 2005: Qt 4.0 – compatibility break, leads to new KDE 4 desktop
Q p y , p
● 2008: Nokia purchases Qt, name changes first to Qt Software, then to Qt Development Frameworks
● 2009 / 2010: Focus on mobile platforms (Symbian, Maemo, MeeGo), dedicated mobility APIs
4 Andreas Jakl, 2010
5. Customers
5 Andreas Jakl, 2010 … and many, many more!
6. Qt Licensing
● LGPL license
● Qt is completely free!
− Unlike GPL, the LGPL:
Unlike GPL the LGPL
– Allows using Qt for free in commercial, closed source apps
− Complete development source code of Qt available
C l t d l t d f Qt il bl
● Commercial version
− Code changes to Qt source code don’t have to be shared
− Included support options
6 Andreas Jakl, 2010
7. Platforms Windows
Mac OS
Linux / X11
Linux / X11
C++ Embedded Linux
Windows CE
Windows CE
Maemo / MeeGo
Java Symbian (S60)
S bi (S60)
Python
Ada
Pascal
Maintained by
Perl
Qt open source community.
PHP Not officially supported by Qt Development Frameworks.
Not officially supported by Qt Development Frameworks
7 Andreas Jakl, 2010
9. Symbian and
Symbian and Qt
● Symbian^4: replaces S60 with Qt‐based UI
y p Q
● Components:
− Uiemo (UI Extensions for Mobile, Orbit):
extension library for Qt, 50+ UI elements
tailored for mobile
t il d f bil
− Direct UI: new app framework based on
Uiemo
● Availability: end of 2010 Symbian^4 Concept Video
9 Andreas Jakl, 2010
10. Maemo and
Maemo and Qt
● Maemo 5
− GTK+ based UI
− Final Qt support: H1 2010
Final Qt support: H1 2010
● Maemo 6
− Qt replaces GTK+
replaces GTK+
− Multi‐touch, gestures support
− MeeGo
M G compatible
tibl
− GTK and Clutter will stay in MeeGo
10 Andreas Jakl, 2010
11. MeeGo and Qt
MeeGo and Qt
● Moblin (Intel) and Maemo (Nokia) merge to
( ) ( ) g
− New Linux distribution
− MeeGo UI toolkit based on Qt
lki b d
− GTK and Clutter included for application compatibility
11 Andreas Jakl, 2010
12. Qt Architecture
● Qt uses native styles to draw UI
− UI elements have original
look & feel
− Can be adapted by the
Can be adapted by the
developer
● Built on low level APIs of platform
− No runtime!
● Cross‐platform
− Single source for multiple
Si l f li l
platforms
− Only requires recompilation
12 Andreas Jakl, 2010
13. Qt Modules
Module Description
QtCore Core non‐graphical classes used by other modules
QtGui Graphical user interface (GUI) components
QtMultimedia Classes for low‐level multimedia functionality
QtNetwork Classes for network programming
QtOpenGL OpenGL support classes
QtOpenVG OpenVG support classes
QtSc pt ( oo s)
QtScript (Tools) Make C++ applications scriptable through ECMAScript‐based language
a e app ca o s sc p ab e oug Sc p based a guage
QtSql Classes for database integration using SQL
QtSvg Classes for displaying contents of SVG files
QtWebKit Classes for displaying and editing web content
Classes for displaying and editing web content
QtXml Classes for handling XML
QtXmlPatterns An XQuery & XPath engine for XML and custom data models
Phonon
Ph Multimedia framework classes
M l i di f k l
13 Andreas Jakl, 2010
15. Hello World Project
World Project
main.cpp
#include <QApplication>
#include <QPushButton>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QPushButton helloButton("Hello World");
helloButton.resize(150, 50);
helloButton.show();
return app.exec();
}
15 Andreas Jakl, 2010
16. Deploy
● Run your Qt application on all platforms!
y Q pp p
Windows 7 Maemo 5 Symbian^1
y
(S60 5th Edition)
16 Andreas Jakl, 2010
17. Qt and C
Qt and C++
● Q g
Qt goes beyond C++
y
− Seamless object communication
( g
(signals & slots)
)
− Meta object system, featuring
object properties and object trees
j p p j
− Contextual string translation for
internationalization
● … but still works with standard C++
compilers on all platforms!
17 Andreas Jakl, 2010
18. Interactivity: Quit
Interactivity: Quit Hello World
● Add functionality to exit the Hello World example:
y p
QObject::connect(&helloButton, SIGNAL(clicked()),
&app,
&app SLOT(quit()));
− Button emits clicked() signal
− Connected to QApplication::quit()
18 Andreas Jakl, 2010
19. Signals & Slots
Signals & Slots
● Signal
− Emitted when a particular event occurs (e.g., clicked())
− Qt widgets: predefined signals
− Also create your own signals
● Slot
− Function called in response to a signal
− Qt widgets: predefined slots (e.g., quit())
− Also create your own slots
Al t l t
● Connection signals slots established by developer,
handled by Qt framework
y
19 Andreas Jakl, 2010
21. Qt Quick (Qt User Interface Creation Kit)
Qt Quick (Qt User Interface Creation Kit)
● Create UIs as a designer
g
− Without C++ knowledge
− Using visual tools
Using visual tools
− Module: Declarative UI
− Based on QML l
B d QML language
(extension to JavaScript)
− Supported in Qt 4.7
Supported in Qt 4 7
− http://blog.qt.nokia.com/2010/02/15/meet‐qt‐quick/
21 Andreas Jakl, 2010
22. QML
● Describe UI by tree structure of
y
property bindings
− Properties dynamically evaluated
dynamically evaluated
Rectangle {
− Communication through width: 200
signals & slots
signals & slots height: 200
height: 200
color: "white"
− Bindings to C++ code possible Image {
source: pics/logo.png
source: "pics/logo png"
− Animate properties using states anchors.centerIn: parent
and transitions }
}
22 Andreas Jakl, 2010
23. UI Frameworks (Dui, Uiemo)
UI Frameworks (Dui, Uiemo)
● Scene graph approach to the UI
g p pp
● Optimized for Maemo 6 UI Framework Widget Demo
(15.2.2010)
− Graphics effects, 3D HW acceleration
− Gestures, multi‐touch, kinetics
● Adventurous?
− Maemo: http://qt.gitorious.org/maemo‐6‐ui‐framework
Maemo http //qt gitorious org/maemo 6 ui framework
− Symbian: http://qt.gitorious.org/uiemo
23 Andreas Jakl, 2010
24. Hybrid Applications
Hybrid Applications
HTML App
Qt Web
Technology
Qt
24 Andreas Jakl, 2010 From: Rajesh Lal
http://www.slideshare.net/rajeshlal/hybrid‐application‐development‐for‐maemo‐n900‐device
25. Advantages of Hybrid Applications
Advantages of Hybrid Applications
Web Qt
HTML, CSS, JavaScript C++
Rapid development
p p Full device access
Broad reach Powerful libraries
Embed Qt UI elements into HTML page
Access Qt objects from JavaScript
j p
Trigger JavaScript from Qt
Shared storage
25 Andreas Jakl, 2010
http://qt.nokia.com/forms/whitepapers/reg‐whitepaper‐hybrid
26. Qt Mobility
Qt Mobility
● Q
Qt: Desktop → Mobile
p
● Requires new APIs for
− Sensors
S
− Location
− Messaging
− etc.
● Qt Mobility: new cross‐platform APIs for mobile use cases
− Back‐end implementation on all platforms where it makes sense
Back‐end implementation on all platforms where it makes sense
26 Andreas Jakl, 2010
27. Qt 4.7
● Q
Qt 4.7 Tech Preview: March 2010
− Includes Qt Quick
− Integrates f
first parts of Qt Mobility
f bili
− Focus on performance
● http://qt.nokia.com/developer/qt‐roadmap
27 Andreas Jakl, 2010
28. Qt Books
C++ GUI Programming with Qt 4 (2nd edition)
C++ GUI Programming with Qt 4 (2
Jasmin Blanchette, Mark Summerfield. Prentice Hall.
Official book for Qt development. Quite complete, but its structure could
be improved.
be improved.
Status: Qt 4.3, 2008
Foundations of Qt Development
Johan Thelin. Apress.
More in‐depth and technically oriented explanation of Qt. Most other
More in depth and technically oriented explanation of Qt. Most other
books are rather similar to the official documentation that you get for free
with the SDK – this is different, and is therefore a good companion.
Status: 2007
28 Andreas Jakl, 2010
29. Even More Information
Even More Information
Qt for Symbian
for Symbian
Editors: Frank H. P. Fitzek, Tommi Mikkonen, Tony Torp.
For Qt developers wanting to get started with development on the mobile
Symbian platform, or the other way round.
Symbian platform, or the other way round.
Status: Qt 4.6, March 2010
Online: qt.nokia.com, www.forum.nokia.com, www.qtcentre.org
Lots of documentation and examples installed with SDK
29 Andreas Jakl, 2010