Presentation is loading. Please wait.

Presentation is loading. Please wait.

1. 2 Qt Toolkit ● C++ toolkit for cross-platform GUI application development – GUI functions (GUI = graphical user interface) – Data access components,

Similar presentations


Presentation on theme: "1. 2 Qt Toolkit ● C++ toolkit for cross-platform GUI application development – GUI functions (GUI = graphical user interface) – Data access components,"— Presentation transcript:

1 1

2 2 Qt Toolkit ● C++ toolkit for cross-platform GUI application development – GUI functions (GUI = graphical user interface) – Data access components, network connections, process management ● Portability across Microsoft Windows, Mac OS X, Linux, all major commercial Unix variants ● Developed by the company Trolltech – http://doc.trolltech.com http://doc.trolltech.com ● The basis of many thousands of successful applications worldwide (eg. KDE) ● Released in different editions – The Qt Commercial Editions - for commercial software development – The Qt Open Source Editions - for the development of Free and Open Source software only (GNU General Public License)

3 3 Logical Layers ● Qt is a layer on the top of the native graphics of the target machine.

4 4 Signals and Slots... ● Communication mechanism between the Qt components ● A signal is emitted when a particular event occurs. – Qt's widgets have many predefined signals, but we can always subclass widgets to add our own signals to them. ● A slot is a function that is called in response to a particular signal. – Qt's widgets have many pre- defined slots, but it is common practice to subclass widgets and add your own slots.

5 5... Signals and Slots ● Example - DrawQt Click on the button “ellipse” ● When you click on the button: – The button sends the signal “clicked” – This signal is connected to the method "ClickEllipse()" – The method "ClickEllipse()" is executed

6 6 Signal and Slots Definition #include “MyClass.h” … // Emit the signal event() emit(event());... // Connect event() signal with // action() slot connect(myClass, SIGNAL(event(), myClass, SLOT(action());... File MyClass.cxx #include class myClass : public QObject { Q_OBJECT … signals: void event(); … public slots: void action(); … }; File MyClass.h

7 7 Meta-Object Information ● The meta-object compiler (moc) parses the class declaration in a C++ file and generates C++ code that initializes the meta-object. ● The meta-object contains the names of all the signal and slot members, as well as pointers to these functions. myClass.h myClass.cxx moc_myClasse.cpp moc myClass.o g++

8 8 Qt Designer ● A tool for designing and building graphical user interfaces (GUIs) from Qt components – It allows you to design and build widgets and dialogues using on-screen forms using the same widgets that will be used in your application. – Components created with Qt Designer can also take advantage of Qt's signals and slots, and they can be previewed so that you can ensure that they will look and feel exactly as you intended. ● The user-interface compiler (uic) reads a user interface definition (.ui) file in XML as generated by Qt Designer and creates corresponding C++ header or source files. – It also generates an image file that embeds raw image data in C++ source code. Interface Description Save myFile.ui uic myFile.h

9 9 Qt Application #include int main(int argc, char* argv[]) { QApplication app(argc, argv); QPushButton hello("Hello world!"); hello.resize(100, 30); hello.show(); return app.exec(); } File main.cxx Create a Qt application Create a graphics button Resize the button Show the button Run the application (and wait for a signal)


Download ppt "1. 2 Qt Toolkit ● C++ toolkit for cross-platform GUI application development – GUI functions (GUI = graphical user interface) – Data access components,"

Similar presentations


Ads by Google