Presentation is loading. Please wait.

Presentation is loading. Please wait.

Qt Programming.

Similar presentations


Presentation on theme: "Qt Programming."— Presentation transcript:

1 Qt Programming

2 Introduction Early widget toolkits for X included Xaw (the Athena Widget Set, 1983), OLIT (OPEN LOOK Intrinsics Toolkit, 1988), XView (1988), Motif (1980s) and Tk. OLIT and XView function as the base toolkits for Sun's legacy OpenWindows desktop environment. Toolkits developed more recently include Qt (1991- , used by KDE), GTK+ (1997- , used by GNOME), wxWidgets (1992), FLTK (1998- ), FOX (1997- ) and fpGUI (2005-current).

3 Cont.. Qt is a cross-platform application framework that is widely used for developing application software with a graphical user interface (GUI) (in which cases Qt is classified as a widget toolkit) Also used for developing non-GUI programs such as command-line tools and consoles for servers. Used in Autodesk Maya, Adobe Photoshop Elements, OPIE, Skype, VLC media player, VirtualBox

4 Cont.. Developed by an open source project with individual developers as well as developers from nokia, digia Prior to the launch of the Qt Project, it was produced by Nokia's Qt Development Frameworks division, which came into being after Nokia's acquisition of the Norwegian company Trolltech, the original producer of Qt. Then Nokia announced the sale of  Qt's commercial licensing and professional services to Digia PLC.

5 Cont.. Qt uses standard C++ but makes extensive use of a special code generator (called the Meta Object Compiler, or moc) together with several macros to enrich the language. Qt can also be used in several other programming languages via language bindings. 

6 Cont.. It runs on the major desktop platforms and some of the mobile platforms. It has extensive internationalization support. Non-GUI features include SQL database access, XML parsing, thread management, network support, and a unified cross-platform API for file handling.

7 Platforms Windows – Qt for Microsoft Windows
Windows CE / Mobile – Qt for Windows CE/Windows Mobile Symbian – Qt for the Symbian platform.  Mac OS X – Qt for Apple Mac OS X. Support for applications on top of Cocoa APIs X11 – Qt for X Window System (GNU/Linux, FreeBSD, HP-UX, Solaris, AIX, etc.) Embedded Linux – Qt for embedded platforms (PDA, Smartphone, etc.)

8 Editions There are three editions of Qt available on each of these platforms, namely: GUI Framework – commercial entry level GUI edition, stripped of network and database support (formerly known as "Desktop Light") Full Framework – complete commercial edition Open Source – complete Open Source edition

9 Current Trolltech released Qt 4.0 on June 28, 2005 and introduced five new technologies in the framework: Tulip A set of template container classes. Interview A model/view architecture for item views. Arthur A 2D painting framework. Scribe A Unicode text renderer with a public API for performing low-level text layout. MainWindow A modern action-based main window, toolbar, menu, and docking architecture.

10 Modules Modules for working with Qt's tools QtDesigner QtUiTools
QtHelp QtTest

11 Metaobject compiler The metaobject compiler, termed moc, is a tool that is run on the sources of a Qt program. It interprets certain macros from the C++ code as annotations, and uses them to generate additional C++ code with "Meta Information" about the classes used in the program. This meta information is used by Qt to provide programming features not available natively in C++: the signal/slot system, introspection and asynchronous function calls

12 Qt Program #include <qapplication.h>
#include <qpushbutton.h> int main( int argc, char **argv ) { Qapplication a( argc, argv ); QPushButton hello( "Hello world!", 0 ); hello.resize( 100, 30 ); a.setMainWidget( &hello ); hello.show(); return a.exec(); }

13 Explaination #include <qapplication.h>
This line includes the QApplication class definition. There has to be exactly one QApplication object in every application that uses Qt. QApplication manages various application-wide resources, such as the default font and cursor.

14 Cont.. #include <qpushbutton.h>
This line includes the QPushButton class definition. QPushButton is a classical GUI push button that the user can press and release. It manages its own look and feel, like every other QWidget. A widget is a user interface object that can process user input and draw graphics. The programmer can change both the overall look and feel and many minor properties of it (such as color), as well as the widget's content. A QPushButton can show either a text or a QPixmap.

15 Cont.. int main( int argc, char **argv ) {
The main() function is the entry point to the program. Almost always when using Qt, main() only needs to perform some kind of initialization before passing the control to the Qt library, which then tells the program about the user's actions via events. argc is the number of command-line arguments and argv is the array of command-line arguments. This is a C/C++ feature.

16 Cont.. QApplication a( argc, argv );
a is this program's QApplication. Here it is created and processes some of the command-line arguments (such as -display under X Window). QPushButton hello( "Hello world!", 0 ); Here, A push button is created. hello.resize( 100, 30 ); The button is set up to be 100 pixels wide and 30 pixels high

17 Cont.. a.setMainWidget( &hello ); hello.show(); return a.exec();
The push button is chosen as the main widget for the application. If the user closes a main widget, the application exits. hello.show(); A widget is never visible when you create it. You must call show() to make it visible. return a.exec(); This is where main() passes control to Qt, and exec() will return when the application exits. In exec(), Qt receives and processes user and system events and passes these on to the appropriate widgets.

18 Compiling To compile a C++ application you need to create a makefile.
The easiest way to create a makefile for Qt is to use the qmake build tool supplied with Qt. qmake -project qmake The first command tells qmake to create a .pro (project) file. The second command tells it to create a (platform-specific) makefile based on the project file. You should now be able to type make (or nmake if you're using Visual Studio) and then run your first Qt application!


Download ppt "Qt Programming."

Similar presentations


Ads by Google