C++ class library. •. Development tools ... Code needs to be rebuild for each
platform. • native binaries ... However, nowadays Qt is much more than plain GUI
framework .... Like Observer Design Pattern but more flexible. •. Objects may emit
...
Introduction to Qt Satakunta SW Forum 28-Oct-2009
Jaakko Vuori
Agenda •
Qt in general
•
What’s inside Qt? • •
•
modules tools
Architectural considerations
2
© 2008 Digia Plc
Qt in general
What is Qt? •
Cross-platform application programming framework • • •
•
Set of APIs C++ class library Development tools
Ported in various platforms •
Desktops •
•
Mobile platforms •
•
e.g. Linux, Windows, MacOS e.g. Maemo, WinCE, S60
Qt is pronounced as “cute”
4
© 2008 Digia Plc
Cross-platform •
Qt is cross-platform in source code level • • •
Code needs to be rebuild for each platform native binaries possibility to use platform specific APIs is needed
•
Platform specialties are isolated behind the API
•
Native look-and-feel in all platforms
5
© 2008 Digia Plc
What can Qt be used for? •
GUI has been the driving force • •
•
Initially there even wasn’t other modules Console applications and daemons are also possible
However, nowadays Qt is much more than plain GUI framework •
Networking, SQL, XML, multimedia, web technologies, etc.
6
© 2008 Digia Plc
Some programs developed with Qt •
KDE and KDE’s applications
•
Adobe Photoshop Albums
•
Google Earth
•
Skype
•
Opera web browser
7
© 2008 Digia Plc
Brief history •
•
Development begun in 1991 by Haavard Nord and Eirik Chambe-Eng Trolltech company was founded in 1994 • •
•
HQ in Oslo Main products were Qt Framework and Qt Extended (formerly known as Qtopia platform)
Nokia acquired Trolltech in 2008 • •
Trolltech renamed to Qt Software Renamed again to Qt Development Frameworks
8
© 2008 Digia Plc
Licensing •
Originally dual licensed • •
• •
Commercial license for closed source projects GPL license for open source projects
First GPL’ed Windows version was Qt 4.0 (in 2005) From Qt 4.5 and onwards (on March 2009) Qt is also available as LPGL license
9
© 2008 Digia Plc
Why Qt? •
High productivity • •
“Write once – deploy everywhere” “Code less”
•
Flexible licensing
•
Object oriented •
•
No oldish “granny-C”
Fun to use • •
Well designed APIs Doesn’t suck™
10
© 2008 Digia Plc
Qt Modules
Modules QtOpenGl
QtSvg
QtGui
QtSql
QtWebKit
QtXmlPatterns
QtNetwork
QtXml
Qt3Support
QtScript
Phonon
QtCore
12
© 2008 Digia Plc
QtCore •
QObject •
•
QCoreApplication •
•
•
e.g. QFile, QTextStream
Threads and processes •
•
e.g. QList, QVector, QMap
File access •
•
e.g. QString, QChar
Containers •
•
Console application’s event loop
Data types •
•
Heart of Qt’s object model
e.g. QThread, QProcess, QMutex
Timers etc.
13
© 2008 Digia Plc
QtGUI •
Widget library •
•
Toolbar, Tabs, Status bar, Splash screen, progress, Menu, Line Edit, Label, LCD Number, Text Edit, List View, Tree View, Calendar, Slider, Buttons, etc.
Dialogs •
Progress, Message, Input, Font, File, Error, Color, Printing, etc.
•
Widget layout management
•
MainWindow
•
GraphicsView
14
© 2008 Digia Plc
Some other modules •
QtNetwork •
•
QtSQL •
•
read/write XML data
QtTest •
•
Web browser
QtXml •
•
MySQL, Oracle, ODBC, PostgreSQL, Sybase, IBM DB2, SQLite, Borland InterBase
QtWebKit •
•
TCP, UDP, FTP/HTTP client, URL parsing
Built-in unit test framework
QtDBus •
IPC mechanism for Linux
15
© 2008 Digia Plc
Qt for mobile platforms • •
• •
Qt is originally developed for desktops Qt currently provides no APIs for mobile devices related features QtMobility will fill this gap in future Interim solution for mobility needs is provided by Qt/S60 Mobile Extensions •
•
•
Set of special APIs covering mobile devices related features currently not supported by official Qt Camera, Contacts, Location, Messaging, Sensor, Vibra, etc. Qt for S60 only
16
© 2008 Digia Plc
Qt Tools
Build tools •
configure •
•
qmake • •
•
script that configures Qt itself for different platforms creates platform specific make files and workspaces hides platform specific building specialties
code generators •
Meta-Object Complier (MOC) • •
•
UI Compiler (UIC) •
•
Generates meta-object C++ source files based on keywords more info later Converts .ui (XML) files to C++ header files
RCC •
Resource compiler
18
© 2008 Digia Plc
Development tools •
Qt Designer • •
•
Qt Assistant • •
•
Drag and drop GUI layout and forms builder writes results in .ui files (XML) Excellent documentation Examples
Qt Linguist •
Localization tool
19
© 2008 Digia Plc
Qt Creator – a cross-platform IDE •
Smart code editor
•
Project wizard
•
Integrated help
•
Integrated UI designer
•
Debugging interface
20
© 2008 Digia Plc
Architectural considerations
Meta-Object System •
Qt’s way to extends standard C++ • • •
Run-time type information Signal-slot mechanism Dynamic/discoverable properties • •
•
•
Run-time translation of strings
The trick is done at compile-time •
•
property name as a string add new properties run-time
Meta-Object compiler (MOC) reads a C++ source file and generates another source file containing meta-object code
qmake does all the hard work so developers may just use the advantages of the Meta-Object System
22
© 2008 Digia Plc
Signals and slots •
Like Observer Design Pattern but more flexible • •
Objects may emit signals Objects may receive signals in their slots •
•
Slot is also a normal method
Signals and slots are connected together
•
Many-to-many relationship
•
Loose coupling • •
• •
Objects don’t have to know each others Still the parameters passed with signals are type-safe
Qt’s classes typically provide lots of signals and slots Signals-slot mechanism can be utilized in own classes as well
23
© 2008 Digia Plc
Signals and slots connect(Object1, signal1, Object3, slot1)
Object1
connect(Object1, signal1, Object3, slot2)
Object3
signal1
signal1
signal2
signal2 slot1 slot2 connect(Object1, signal2, Object4, slot2)
Object2
Object4
signal1
signal1
signal2
signal2 slot1
slot1
slot2 slot3 connect(Object2, signal1, Object4, slot1)
24
© 2008 Digia Plc
Thank You!
[email protected] www.digia.com