Download presentation
Presentation is loading. Please wait.
Published byGwendoline Wilson Modified over 9 years ago
1
Qt Igor November 8, 2002 Friday’s HENP Group Meeting
2
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 XP UNIX (X11) : most popular flavors Mac 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)www.trolltech.com Commercially introduced in early 1996
3
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
4
Modules and Editions
5
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
6
Multi-platform applications development Qt Object Model QtDesigner … Most interesting features
7
#include int main( int argc, char **argv ) { QApplication app( argc, argv ); QLabel hello( " Hello Qt! “, " ", 0 ); app.setMainWidget( &hello ); hello.show(); return app.exec(); }
8
Qt Object Model Qt 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
9
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”)
10
Signals and Slots
12
#include 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(); }
13
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
14
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).
15
MOC Example class MyClass : public QObject { Q_OBJECT public: MyClass( QObject* parent=0, const char* name=0 ); ~MyClass(); signals: void mySignal(); public slots: void mySlot(); };
16
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; };
17
QtDesigner Approach
18
QtDesigner Approach : 1
19
QtDesigner Approach : 2
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.