Professional Documents
Culture Documents
Qt basics: About me
Qt basics: Overview
What is Qt?
Qt basics: Overview
What is Qt?
Qt is a cross-platform application
and UI framework.
Application 1
Application 3
Qt APIs
Qt
Application 2
Qt/Windows
Qt/Mac
Qt/Unix
Win32 GDI
Carbon / Cocoa
X11
Windows Kernel
Mac Kernel
Linux Kernel
HW
What is Qt?
Official support
Embedded Linux
Mac OS X
Windows
Linux/X11
Windows CE
S60
MeeGo
What is Qt?
According to Wikipedia
( http://en.wikipedia.org/wiki/Qt_(t
oolkit) ) there's bindings to Qt from:
Python
QtAda
Pascal
FreePascal Qt4
Qtcl
Common Lisp
DaoQt
TCL
Lqt
Dao
QtRuby
Qt Haskell
Lua
PHP-Qt
Haskell
Qyoto
Ada
Perl Qt4
PHP
Ruby
Jambi (LGPL)
C#
Perl
Java
PySide (LGPL)
PyQt (GPL & commercial)
PythonQt (LGPL)
CommonQt
QtD
QtCore http://qt.nokia.com/doc/qtcore.html
http://doc.trolltech.com/qcoreapplication.html
QtNetwork http://qt.nokia.com/doc/qtnetwork.html
QtXml http://qt.nokia.com/doc/qtxml.html
QtXMLPatterns http://
doc.qt.nokia.com/qtxmlpatterns.html
QtSql http://doc.qt.nokia.com/qtsql.html
10
...multiple ways
http://qt.nokia.com/doc/gallery.html
http://qt.nokia.com/doc/qtgui.html
QtOpenGL http://qt.nokia.com/doc/qtopengl.html
The QtOpenGL module offers classes that make it easy to use
OpenGL in Qt applications.
Examples can be found from: http://
qt.nokia.com/doc/examples.html#opengl
11
QtWebkit http://qt.nokia.com/doc/qtwebkit.html
QtWebKit provides a web browser engine that makes it
easy to embed content from the World Wide Web into
your Qt application.
http://qt.nokia.com/doc/examples.html#webkit
QtSvg http://qt.nokia.com/doc/qtsvg.html
12
Jobs?
13
Pointers
References
Macros
Templates
All that weird stuff
14
Source: http://qt.nokia.com/doc/object.html
http://qt.nokia.com/doc/objecttrees.html
Implemented with QObjects
http://doc.trolltech.com/shared.html
15
http://qt.nokia.com/doc/signalsandslots.html
Implemented through MOC
http://qt.nokia.com/doc/moc.html#moc
http://qt.nokia.com/doc/eventsandfilters.html
http://qt.nokia.com/doc/properties.html
Implemented through MOC
http://qt.nokia.com/doc/moc.html#moc
16
http://qt.nokia.com/doc/i18n.html
Simply use QObject::tr(Text);
http://qt.nokia.com/doc/timers.html
Well leave these out, but its good to mention them.
17
http://qt.nokia.com/doc/moc.html#moc
Provides us the Qts Meta-Object System
http://qt.nokia.com/doc/metaobjects.html
18
Source: http://qt.nokia.com/doc/objecttrees.html
19
Construction/Destruction Order of
QObjects
Of course you have to create the QObject before you can use it
as a parent.
20
Construction/Destruction order of
QObjects
parent
child
child
child
child
21
We do a delete on one
child:
parent
child
child
child
child
22
We get:
parent
child
23
child
Image source:
http://www.apartmentther
apy.com/uimages/ny/4-17stack-drawers-1.jpg
24
Source: http://en.wikipedia.org/wiki/Call_stack
25
Source:
http://en.wikipedia.org/wiki/Dynamic_memory_allocation
like in C++
like in Java and C#
26
Source: http://doc.trolltech.com/shared.html
they might not always be storing all the data in the stack
a reference count
the data.
27
reference count
data
28
29
a reference count
"foo
30
the foo and bar now actually point to the SAME data block
only the reference count was increased
31
Source: http://labs.trolltech.com/blogs/2009/08/25/count-with-me-how-many-smart-pointer-classesdoes-qt-have/
QSharedDataPointer /
QExplicitlySharedDataPointer
QSharedPointer
32
33
Source: http://qt.nokia.com/doc/signalsandslots.html
34
35
36
Source: http://doc.trolltech.com/eventsandfilters.html
37
Source:
http://qt.nokia.com/doc/eventsandfilters.html#howevents-are-delivered
As event occurs
http://doc.trolltech.com/qevent.html
ie. QMouseEvent, QKeyEvent, QPaintEvent
38
39
Event types
Source:
http://qt.nokia.com/doc/eventsandfilters.html#eventtypes
http://qt.nokia.com/doc/qevent.html
40
Event types
QResizeEvent http://qt.nokia.com/doc/qresizeevent.html
QPaintEvent http://qt.nokia.com/doc/qpaintevent.html
Mouse events!
QKeyEvent http://qt.nokia.com/doc/qkeyevent.html
Paint events!
QMouseEvent
http://qt.nokia.com/doc/qmouseevent.html
Resize events!
Key events!
QCloseEvent http://qt.nokia.com/doc/qcloseevent.html
41
Event handlers
Source:
http://qt.nokia.com/doc/eventsandfilters.html#eventhandlers
like QWidget
42
Event filters
Source:
http://qt.nokia.com/doc/eventsandfilters.html#eventfilters
QObject::installEventFilter()
http://qt.nokia.com/doc/qobject.html#installEventFilter
43
Source: http://qt.nokia.com/doc/properties.html
44
45
Source: http://qt.nokia.com/doc/moc.html#moc
Q_OBJECT
Q_PROPERTY
Q_ENUMS
signals:
public slots:
private slots:
46
47
48
Implement QWidget::paintEvent(QPaintEvent*)
do custom painting with QPainter
http://doc.trolltech.com/stylesheet.html
http://doc.trolltech.com/qpainter.html
Qt Quick
Custom UI
Declarative description of the UI with EcmaScript
49
50
51
How do I do events?
Sending events
bool QCoreApplication::sendEvent(QObject*
receiver, QEvent* event)
Receiving events
paintEvent
resizeEvent
etc
52
53
How do I do components?
54
How do I do components?
public
public slots
increment()
increment(int amount)
decrement()
setValue(int newValue)
signals
int value()
valueChanged(int newValue)
valueChanged(const QString& value)
valueChangedDelta(int delta)
private
int m_value
55
How do I do components
56
How do I do components?
Let's do a CarCalculator
57
How do I do components?
58
How do I do components?
59
How do I do components?
60
Qt Quick
http://doc.qt.nokia.com/qtquick.html
Qt Quick is concept of
Tools:
QtCreator
QML Designer
QMLViewer
QML language
Declarative Runtime (interprets QML code)
61
QML
Script language
Uses JavaScript as glue code for controlling the behaviour of
the user interface
Declarative way to define UI behaviour
Contains set of very basic user interface controls called as QML
elements for example
http://doc.qt.nokia.com/qdeclarativeelements.html
Rectangle
Text
Image
Flickable
62
QML
63
Qt Quick links
Qt Quick documentation
https://projects.forum.nokia.com/qtquickplayground
Qt Bubble Level
http://doc.qt.nokia.com/qtquick.html
Qt Quick Playground
http://qt.nokia.com/downloads/
https://projects.forum.nokia.com/qtbubblelevel
http://wiki.forum.nokia.com/index.php/Category:Qt_Qui
ck
64
Questions?
65
Thank You!
tarmo.aidantausta@digia.com