intro to qt - missouri s&t - missouri university of...
TRANSCRIPT
An Introduction to Qt 4An Introduction to Qt 4
Jason TrentJason Trentjtrent@[email protected]
OutlineOutline
Why Trolltech?Why Trolltech? Why Qt?Why Qt? Qt 4 Widgets, Qt 4 Widgets, DatatypesDatatypes, and Structures, and Structures Qt DesignerQt Designer qmakeqmake Qt without C++Qt without C++ DemoDemo
Why Trolltech?Why Trolltech?
Qt and Qt and Qtopia Qtopia Core are Open SourceCore are Open Source Supported by multi-million dollarSupported by multi-million dollar
companycompany
Why Qt?Why Qt?
Multi-platformMulti-platform–– No No ““virtual machinesvirtual machines”” or emulation layers or emulation layers–– Native compilationNative compilation for Windows, X11, and Macfor Windows, X11, and Mac
•• Utilizes core OS technologies (Core, Aero, Utilizes core OS technologies (Core, Aero, ……))
–– Extensions - Extensions - ActiveQtActiveQt, Motif Migration, Motif Migration
Why Qt?Why Qt?
Not justNot just a GUI toolkita GUI toolkit–– File handlingFile handling–– NetworkingNetworking–– Process handlingProcess handling–– ThreadingThreading–– DDatabase accessatabase access–– EEvent loop processingvent loop processing–– XML processingXML processing–– OpenGL integrationOpenGL integration–– and beyondand beyond
Over 400 C++ Classes
Why Qt?Why Qt?
InternationalizationInternationalization–– Built in support for Unicode and TranslationBuilt in support for Unicode and Translation
•• Language and font aware layoutsLanguage and font aware layouts•• Bidirectional font supportBidirectional font support•• Mixed-international interfaceMixed-international interface
See See Qt LinguistQt Linguist for more for more
Why Qt?Why Qt?
Not just Not just mutli-platiformmutli-platiform, , multi-architecturemulti-architecture Qtopia Qtopia Core 4 SeriesCore 4 Series
–– Support for embedded devicesSupport for embedded devices•• Cell phones, Cell phones, PDAsPDAs, etc, etc……
–– Supports Qt4 widgets with little to no codeSupports Qt4 widgets with little to no codechangechange
QWidgetQWidget
The meek may inherit the earthThe meek may inherit the earth…………but the earth shall inherit but the earth shall inherit QWidgetQWidget
QWidget
Qt 4 WidgetsQt 4 Widgets
Inherit the all-powerful Inherit the all-powerful QWidgetQWidget Include:Include:
–– QLabelQLabel–– QPushButtonQPushButton–– QTextBoxQTextBox–– QDialogQDialog–– QFileDialogQFileDialog–– Many, many moreMany, many more
Signals and SlotsSignals and Slots
ProvideProvide communication between objectscommunication between objects A signal is emitted and slots reactA signal is emitted and slots react Getters and SettersGetters and Setters FunctionsFunctions
Qt 4 Qt 4 Datatypes Datatypes & Structures& Structures
Advanced Advanced datatypesdatatypes–– QStringQString–– QDataStreamQDataStream
StructuresStructures–– QListQList–– QVectorQVector–– QMapQMap
Qt DesignerQt Designer
Powerful stand-alone interface builderPowerful stand-alone interface builder Ability to Ability to integrateintegrate into into IDEsIDEs
–– KdevelopKdevelop,, Visual Studio, Visual Studio, …… Ability to Ability to previewpreview on target platforms on target platforms
–– Windows, Windows XP, Mac, Windows, Windows XP, Mac, PlastiquePlastique, CDE, and, CDE, andMotifMotif
Extensive Extensive layoutlayout system system–– Auto-scaling, font-aware layoutsAuto-scaling, font-aware layouts–– DynamicallyDynamically adjust layout for font size, direction,adjust layout for font size, direction,
display size, language, operating systemdisplay size, language, operating system
qmakeqmake
One project format to rule them allOne project format to rule them all Maintain .pro project fileMaintain .pro project file
–– Automatically create target projectAutomatically create target project•• MakefileMakefile•• XCodeXCode•• VisualVisual StudioStudio
TEMPLATE = appINCLUDEPATH += .QT += core gui networkTARGET = iBoard
# InputHEADERS += canvas.h \
netconnect.h \scribble.h
FORMS += startup4.ui
SOURCES += canvas.cpp \netconnect.cpp \scribble.cpp \main.cpp
RESOURCES = iBoard.qrc
<!DOCTYPE RCC><RCC version="1.0"> <qresource> <file>images/logo.png</file> <file>images/logo_mask.bmp</file> <file>images/save.png</file> <file>images/clear.png</file> <file>images/pencil.png</file> <file>images/pencil_mask.bmp</file> <file>images/eraser.png</file> <file>images/eraser_mask.bmp</file> <file>images/fill.png</file> <file>images/fill_mask.bmp</file> <file>images/print.png</file> </qresource></RCC>
Makefile
XCode Project (.xcodeproj)
Visual Studio (.vcproj)
qmake qmake Command Line OptionsCommand Line Options
-project-project–– Auto-generate .pro file based on folderAuto-generate .pro file based on folder
contentscontents -spec [-spec [makespecmakespec]]
–– Build the project or make file based on theBuild the project or make file based on themake specificationmake specification•• linux-glinux-g++, ++, macx-xcodemacx-xcode, win32-mingw,, win32-mingw, ……
DemoDemo
Other Items of InterestOther Items of Interest
PyQt PyQt - Qt extensions for Python- Qt extensions for Python PerlQt PerlQt - Qt extensions for - Qt extensions for PerlPerl Qt/Java - Trolltech supported JavaQt/Java - Trolltech supported Java
extensionsextensions–– Coming Q1 2006Coming Q1 2006
ReferencesReferences
Trolltech Trolltech www.trolltech.comwww.trolltech.com Qt ForumQt Forum www.qtforum.orgwww.qtforum.org The Qt4 ResourceThe Qt4 Resource CenterCenter qt4.qt4.digitalfanaticsdigitalfanatics.org.org Qt CentreQt Centre www.qtcentre.orgwww.qtcentre.org C++ GUI Programming in Qt 3C++ GUI Programming in Qt 3 www.phptr.com/perenswww.phptr.com/perens
Slide format and many images from TrolltechSlide format and many images from Trolltech
Code Less. Create More.