qt igor november 8, 2002 friday’s henp group meeting
TRANSCRIPT
![Page 1: Qt Igor November 8, 2002 Friday’s HENP Group Meeting](https://reader036.vdocument.in/reader036/viewer/2022072010/56649dc35503460f94ab5413/html5/thumbnails/1.jpg)
QtIgor
November 8, 2002
Friday’s HENP Group Meeting
![Page 2: Qt Igor November 8, 2002 Friday’s HENP Group Meeting](https://reader036.vdocument.in/reader036/viewer/2022072010/56649dc35503460f94ab5413/html5/thumbnails/2.jpg)
What is Qt?
“…multiplatform C++ GUI application framework…”
“…Qt is fully object-oriented, easily extensible, and allows true component programming…”
Supported platforms
MS/Windows (MFC) : from 95 to XPUNIX (X11) : most popular flavorsMac OS X :Embedded : Linux with frame buffer support
“…Qt is also the basis of the popular KDE Linux desktop environment…”
Qt is a product of Trolltech (www.trolltech.com)
Commercially introduced in early 1996
![Page 3: Qt Igor November 8, 2002 Friday’s HENP Group Meeting](https://reader036.vdocument.in/reader036/viewer/2022072010/56649dc35503460f94ab5413/html5/thumbnails/3.jpg)
Versions and availability
V2.x : Is free for non-commercial development for all platforms. Licenses: QPL or GPL
V3.x : has lots of new stuff compared to v2.x
Is free for non-commercial development for UNIX only. Licenses: QPL or GPL. 30 days free evaluation download is available for MS-Windows and Mac OS X.
Is available in two editions (see next slide) for commercial software development. Prices vary from $1240 to $4370 per license depending on the total number of clients and the Qt edition.
No royalty for resulting applications
![Page 4: Qt Igor November 8, 2002 Friday’s HENP Group Meeting](https://reader036.vdocument.in/reader036/viewer/2022072010/56649dc35503460f94ab5413/html5/thumbnails/4.jpg)
Modules and EditionsModules vs Edition ProfessionalEnterpriseQt Base Modules (Tools, Kernel, Widgets, Dialogs) X X The platform-independent Qt GUI toolk it and utility classesQt Designer X X Visual Qt GUI builderIconview module X X Visualization of sets of pixmaps with user interaction.Workspace module X X Multiple Document Interface (MDI) supportOpenGL 3D Graphics module X Integration of Qt with OpenGLNetwork module X Platform-independent classes for sock ets, TCP, FTP and asynchronous DNS look up.Canvas module X Optimized 2D graphics area for visualization, diagrams, etc.Table module X Flexible and editable table / spreadsheetXML module X Well-formed XML parser with SAX interface and DOM Level 1.SQL module X SQL database access classes.
![Page 5: Qt Igor November 8, 2002 Friday’s HENP Group Meeting](https://reader036.vdocument.in/reader036/viewer/2022072010/56649dc35503460f94ab5413/html5/thumbnails/5.jpg)
What makes Qt a “cool” stuff?
My personal opinion :
It provides “all in one” object oriented framework for the component programming – one of the main practices in the contemporary software development (not in HEP)
A collection of services provided through the framework for the applications developers is nearly complete (for majority of desktop applications). It includes famous “triad”:
• GUI (user interaction)• Database (persistency)• Networking (distributed programming)
QtDesigner
Signal-Slot Objects Communication Model
![Page 6: Qt Igor November 8, 2002 Friday’s HENP Group Meeting](https://reader036.vdocument.in/reader036/viewer/2022072010/56649dc35503460f94ab5413/html5/thumbnails/6.jpg)
• Multi-platform applications development• Qt Object Model• QtDesigner• …
Most interesting features
![Page 7: Qt Igor November 8, 2002 Friday’s HENP Group Meeting](https://reader036.vdocument.in/reader036/viewer/2022072010/56649dc35503460f94ab5413/html5/thumbnails/7.jpg)
#include <qapplication.h>#include <qlabel.h>
int main( int argc, char **argv ){ QApplication app( argc, argv ); QLabel hello( "<font color=blue>Hello <i>Qt!</i>“, "</font>", 0 );
app.setMainWidget( &hello ); hello.show(); return app.exec();}
![Page 8: Qt Igor November 8, 2002 Friday’s HENP Group Meeting](https://reader036.vdocument.in/reader036/viewer/2022072010/56649dc35503460f94ab5413/html5/thumbnails/8.jpg)
Qt Object ModelQt is supposed to add an extra flexibility to the plain C++ Object Model with the following extensions :
- a mechanism for seamless object communication called signals and slots- queryable and designable object properties- events and event filters- contextual string translation for internationalization
- interval driven timers that make it possible to integrate many tasks in an event-driven GUI
- hierarchical and queryable object trees that organize object ownership in a natural way
- guarded pointers, QGuardedPtr, that are automatically set to 0 when the referenced object is destroyed, unlike normal C++ pointers which become "dangling pointers" when their objects are destroyed
![Page 9: Qt Igor November 8, 2002 Friday’s HENP Group Meeting](https://reader036.vdocument.in/reader036/viewer/2022072010/56649dc35503460f94ab5413/html5/thumbnails/9.jpg)
Qt Object Model : 1
The Qt Object Model implementation :
- Standard C++ techniques, based on inheritance from QObject base class
- Meta Object System provided by Qt's own Meta Object Compiler (“moc”)
![Page 10: Qt Igor November 8, 2002 Friday’s HENP Group Meeting](https://reader036.vdocument.in/reader036/viewer/2022072010/56649dc35503460f94ab5413/html5/thumbnails/10.jpg)
Signals and Slots
![Page 11: Qt Igor November 8, 2002 Friday’s HENP Group Meeting](https://reader036.vdocument.in/reader036/viewer/2022072010/56649dc35503460f94ab5413/html5/thumbnails/11.jpg)
![Page 12: Qt Igor November 8, 2002 Friday’s HENP Group Meeting](https://reader036.vdocument.in/reader036/viewer/2022072010/56649dc35503460f94ab5413/html5/thumbnails/12.jpg)
#include <qapplication.h>#include <qpushbutton.h>
int main( int argc, char **argv ){ QApplication app( argc, argv ); QPushButton quit( “Quit”, 0 );
QObject::connect( &quit, SIGNAL( clicked()), &app, SLOT ( quit()));
app.setMainWidget( &quit ); quit.show(); return app.exec();}
![Page 13: Qt Igor November 8, 2002 Friday’s HENP Group Meeting](https://reader036.vdocument.in/reader036/viewer/2022072010/56649dc35503460f94ab5413/html5/thumbnails/13.jpg)
Meta Object System
Provides :
Signals and Slots mechanism for inter-object communication, runtime type information, and the dynamic property system
Is based on :
-the QObject class
-the Q_OBJECT macro inside the private section of the class declaration
- the Meta Object Compiler (moc) to handle C++ extensions
![Page 14: Qt Igor November 8, 2002 Friday’s HENP Group Meeting](https://reader036.vdocument.in/reader036/viewer/2022072010/56649dc35503460f94ab5413/html5/thumbnails/14.jpg)
Meta Object System : 1
How it works :
A developer writes a file using Qt C++ extension
The moc reads a C++ source file. If it finds one or more class declarations that contain the Q_OBJECT macro, it produces another C++ source file which contains the meta object code for the classes that use the Q_OBJECT macro. Among other things, meta object code is required for the signal/slot mechanism, runtime type information and the dynamic property system.
The C++ source file generated by the moc must be compiled and linked with the implementation of the class (or it can be #included into the class's source file).
![Page 15: Qt Igor November 8, 2002 Friday’s HENP Group Meeting](https://reader036.vdocument.in/reader036/viewer/2022072010/56649dc35503460f94ab5413/html5/thumbnails/15.jpg)
MOC Example
class MyClass : public QObject { Q_OBJECTpublic: MyClass( QObject* parent=0, const char* name=0 ); ~MyClass();signals: void mySignal();public slots: void mySlot();};
![Page 16: Qt Igor November 8, 2002 Friday’s HENP Group Meeting](https://reader036.vdocument.in/reader036/viewer/2022072010/56649dc35503460f94ab5413/html5/thumbnails/16.jpg)
MOC Example : 1
class MyClass : public QObject { Q_OBJECT Q_PROPERTY( Priority priority READ priority WRITE setPriority ) Q_ENUMS( Priority )public: ...
enum Priority { High, Low, VeryHigh, VeryLow }; void setPriority( Priority ); Priority priority() const; };
![Page 17: Qt Igor November 8, 2002 Friday’s HENP Group Meeting](https://reader036.vdocument.in/reader036/viewer/2022072010/56649dc35503460f94ab5413/html5/thumbnails/17.jpg)
QtDesigner Approach
![Page 18: Qt Igor November 8, 2002 Friday’s HENP Group Meeting](https://reader036.vdocument.in/reader036/viewer/2022072010/56649dc35503460f94ab5413/html5/thumbnails/18.jpg)
QtDesigner Approach : 1
![Page 19: Qt Igor November 8, 2002 Friday’s HENP Group Meeting](https://reader036.vdocument.in/reader036/viewer/2022072010/56649dc35503460f94ab5413/html5/thumbnails/19.jpg)
QtDesigner Approach : 2