1 / 74

Qt Framework

Qt Framework. Qt History Who uses Qt Benefits Tools and components SDK Core Internals Programming with Qt. Programming with Qt. - Containers (Tulips) - 2D/3D graphics - Widgets - Graphics View - XML - Thread/IPC

raja
Download Presentation

Qt Framework

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Qt Framework Qt History Who uses Qt Benefits Tools and components SDK Core Internals Programming with Qt

  2. Programming with Qt - Containers (Tulips) - 2D/3D graphics - Widgets - Graphics View - XML - Thread/IPC - Interview (MVC) - Phonon - Webkit - Multimedia - Canvas - OpenGL - Database - QML and JavaScript - Networking - Android and iOS

  3. Qt Framework Qt History Who uses Qt Benefits Tools and components SDK Core Internals Programming with Qt

  4. Qt History Pronounce “Cute” or Qt Cross platform application development framework User experience across hardware platforms It goes beyond GUI (database access, xml parser, web, …) It can bind to any language and can be written in C++, python, C#, Ruby, Ada, Pascal, PHP, Perl, and Java.

  5. Qt History Qt Was initially developed by two persons,Haavard Nord (CEO), and EirikChambe(President) in early 90. Both graduated from Norwegian Institute of Technology in Computer Science and formed Throlltech Inc. in 1995. Qt 4 was published in Summer 2005 (major milestone) In 2008 acquired by Nokia (Finnish company) In 2012, acquired by Digia (Finnish company) 3 licenses (GPL/GNU GPL/Commercial) The commercial you don’t have to share the code in open source

  6. QtHistory Traditional C++, but later (4.7) with Qt Quick and QML with JavaScript where it is ideal for tablet/smartphone Leverage with C++ , less learning curve It is high quality, mature, free, excellent support for localization, support 32/64 bit computing Presently Qt 5.2 and Qwt6.1 (latest version) Rich set of Widgets (1000+), Qwt (125+) classes Very Good Documentation, help, and examples QtProject: http://www.qt-project.org DigiaSite: http://qt.digia.com

  7. Qt Framework Qt History Who uses Qt Benefits Tools and components SDK Core Internals Programming with Qt

  8. Who uses Qt European Space Agency Google Earth Skype KDE (Operating System Dist. on Linux) Adobe Photoshop Album (graphics) Autodesk Maya (Animation) VLC (Video) Panasonic and Thales IFE (Airline) Navico (Navigation) Eykona (healing process monitor) Barco (Medical Imaging) Michelin, Intel, HP, Samsung, Blackberry, ABB, AMD, Epson, HONDA, Cannon, …

  9. Qt Framework Qt History Who uses Qt Benefits Tools and components SDK Core Internals Programming with Qt

  10. Benefit Cross platform GUI framework (develop on one machine and port it to any other machine) Rich API class w/ C++ library, along an IDE with different tools to support Superior Graphics performance with power of C++ and Qt Object Model A very powerful mechanism for seamless object communication called signal sand slots (callback system) Query able and designable object properties Contextual string translation for internationalization Sophisticated interval driven timers that make it possible to elegantly integrate many tasks to an event driven GUI Hierarchical and query able object trees that organize object in a natural way Guarded pointers (QPointer) that are automatically set to 0 when the referenced object get destroyed A dynamic cast that works across library boundary

  11. Qt Framework Qt History Who uses Qt Benefits Tools and components SDK Core Internals Programming with Qt

  12. Tools Qt Creator : Cross platform IDE Qt Designer: GUI layout and forms builder QtLinguest: Internationalization toolset Qt Assist: Customizable documentation reader QtQmake: Cross platform build tool Plugin for other IDE: Integration with Visual Studio and Eclipse Configure: Tool to configure Qt on any specific platform Qt SDK: Rich C++ library

  13. Qt Modular Class Library

  14. Building Qt Application (Qmake) Qmake : Creates Qt Project file (.pro) , can also be created manually.: $Qmake –project (generates “hello.pro”) $qmake hello.pro(generates “Makefile”) $make (use nmakeif running on Windows) Qmake : Uses the .pro file as input produces platform specific Makefiles) Generates make rules to invoke moc for project header files containing Q-Object Make: Compiles the program for the current platform Executes also moc, uic and rcc

  15. Qt Framework Qt History Who uses Qt Benefits Tools and components SDK Core Internals Programming with Qt

  16. Qt Architecture

  17. Qt SDK The Qt class library encompasses all the functions needed build robust, high end applications, and they can be separate into several modules: Core Framework - OpenGL framework GUI Framework -2D with Painter framework SQL Framework - Scene Graph framework XML Framework - SVG Framework Networking Framework OpenGL Framework Multimedia Framework WebKitFramework Phonon Framework

  18. Qt Class Library QtCore: File I/O, event and object handling, multi-threading and concurrency, plugins, setting management signals and slots inter-object communications mechanism QtGui: Set of customizable widgets, 2D graphics canvas and OpenGL® integration, powerful font and layout engine style engine and widget style sheets, anti-aliasing, vector deformation, and SVG support, advanced graphics effects support for ARGB top-level widgets

  19. Qt Framework Qt History Who uses Qt Benefits Tools and components SDK Core Internals Programming with Qt

  20. Core Internals Object Model Meta Object System Property System Signal and Slots State Machine Framework Timers

  21. Core Internals Object Model Meta Object System Property System Signal and Slots Event System

  22. Object Model Qt’s Object Model (QObject) GUI programming is a domain that requires both runtime efficiency and a high level of flexibility. Although C++ object model is efficient at runtime but its static nature is inefficient in graphical domain. Qtprovides this, by combining the speed of C++ with the flexibility of the Qt Object Model. Meta-Object system : Allows runtime introspection, manipulation and invocation of properties and methods in the object.

  23. Core Internals Object Model Meta Object System Property System Signal and Slots Event System

  24. Meta Object System The QMetaObject class contains meta-information about Qt objects. Classes must be predefined with Qt “moc” Class declarations must include Q_OBJECT macro Responsible for the signals/slots inter-object communication mechanism, runtime type information, and the Qt property system Qmake takes care of this automatically

  25. Core Internals Object Model Meta Object System Property System Signal and Slots State Machine Framework Timers

  26. Property Systems Provides a sophisticated property system Does not rely on non-standard compiler features like __property or [property]. Works withany standard C++ compiler on every platform Qt supports. To declare a property, use theQ_PROPERTY() macro in a class that inherits QObject. Q_PROPERTY(type name READ getFunction [WRITE setFunction] [RESET resetFunction] [NOTIFY notifySignal] [DESIGNABLE bool] [SCRIPTABLE bool] [STORED bool] [USER bool] [CONSTANT] [FINAL])

  27. Property Systems Keep track of a priority value. priority(name of property) and its type will be enumeration type named Priority class MyClass : public QObject { Q_OBJECT Q_PROPERTY(Priority priorityREAD, priority WRITE, setPriorityNOTIFY priorityChanged) Q_ENUMS(Priority)

  28. Core Internals Object Model Meta Object System Property System Signal and Slots Event System

  29. Callbacks Traditional callbacks (a pointer to a function) Problems: not type safe: does the caller use the correct arguments? Observer Pattern Called when appropriate (event notification, …) Many to many relationship Loose coupling between signals and slots Less generic: callback strongly coupled to processing function Processing function must which callback to call.

  30. Inter-Object Communication The user clicks the OK button -What happens? How do we react to the button press? Answer: -Signals and slots Type safe callbacks Signals are emitted by objects Slots are function that react to signals Slots are regular method calls Handled entirely by Qt’s meta object system

  31. Signals and Slots Same type, and number of parameters Signal and Slots run at the run time Use the “connect” method to join signal and slots connect( slider, SIGNAL( valueChanged( double ) ) , plot, SLOT(setIntervalTime(double))); Predefined signals and slots by classes Otherwise you have to write it depends of what you need In the header file: Q_SIGNALS(signals): Q_SLOTS(slots): Parsed by Qt’s Meta Object Compiler (moc)

  32. Signals A signal is a way to inform a possible observer something of interest has happened inside the observed class A PushButton clicked (an asynchronous service) where the value of Slider is changing. Signals are member functions that automatically implements in the meta-object Only the function declaration is provided by the developer Signal is sent, or emitted using the keyword emit ( i.e. Emit someSignal(“Hello”) )

  33. Slots Regular class member methods Should be declared as void Slots can return a value when called as a method Return values are ignored when invoked from a signal May include in access specifier(pubic, private, ..) A slot is a function that is to be executed when a signal has been emitted: (i.e. when QPushButton is pressed, Close a Qdialog)

  34. Core Internals Object Model Meta Object System Property System Signal and Slots Event System

  35. Event Systems Eventsare objects, derived from abstract QEvent class, usually receives from window system and dispatch it to widgets. When an event occurs, QtCreates an event object (an instance of the QEvent), and therefore delivers to an instance of QObject. Based on the type of event delivered, response will be send if the event was accepted or ignored Such as QMouseEvent and QKeyEvent, come from the window system;

  36. How Events are Delivered When an event occurs, QtCreates an event object (an instance of the QEvent), Delivers it to a particular instance of QObject Based on the type of event delivered, response will be send if the event was accepted or ignored Such as QMouseEvent and QKeyEvent, come from the window system;

  37. How Events are Delivered

  38. Event Types Most events types have special classes, notably  QResizeEvent,  QPaintEvent,  QMouseEvent,  QKeyEvent, QCloseEvent. Each class subclasses QEvent and adds event-specific functions. For example,  QResizeEventaddssize()

  39. Hello World

  40. Hello World

  41. Concepts in Qt Widgets Application Main Window Desktop Integration Dialog Windows Layout Management Model/View Programming

  42. Application Main Window Classes for managing main windows and associated UI components: QMainWindow: is the central class around which applications can be built on top level UI. QDockWidget: provides a widget that can be used to create detachable tool palettes or helper windows. QToolBar: provides a generic toolbar widget that can hold a number of different action-related widgets, such as buttons, drop-down menus, combo boxes, and spin boxes.

  43. Desktop Integration These classes enable developers to take advantage of native services while still using a cross-platform API. QDesktopServices: provides an interface to services offered by the user's desktop environment (such as openUrl()function). QSystemTrayIcon: docks or panels with system trays in which applications can install icons, to display status information, either by updating the icon itself or by showing information in "balloon messages". QDesktopWidget: to monitor the positions of widgets and notify applications about changes to the way the desktop is split over the available screens. This enables applications to implement policies for positioning new windows so that, for example, they do not distract a user who is working on a specific task.

  44. Dialogs

  45. Layout Classes QHBoxLayout:Lines up widgets horizontally. QVBoxLayout: Lines up widgets vertically. QGridLayout: Lays out widgets in a grid. QStackedWidget: Stack of widgets where only one widget is visible at a time QStackedLayout: Stack of widgets where only one widget is visible at a time QFormLayout: Manages forms of input widgets and their associated labels And many more …

  46. Qt Strings Built-in Unicode support, Useful methods (i.e. trimmed(), split()) Cheap copying (implicit sharing) Believe it or not, they can actually contain embedded ‘\0’ characters … Concatenation and formatting: Qstring first = Joe”; Qstring last = “Doe”; Qstringfullname = first + “ “+ last; Qstring fullname2 = Qstring(“%1 %2).arg(first).arg(last)); Translation: QstringtranslatedSend = tr(“Send”);

  47. Qt Strings Splitting/Joining on a delimiter character QString numbers = “1, 2,3,4,45,6,23”; QStringListnums = numbers.split(‘,’); int sum=0; foreach(Qstringnum, numberList) Sum +=num.toInt(); Removing leading or trailing whitespace: QString name = “ Joe Doe”; QStringtrimedName = name.trimmed();

  48. Model/View Programming (1) Qt uses a model/view architecture to manage the relationship between data and the way it is presented to the user. MVC consists of 3kinds of objects, the “Model” is the application object, the “View” is its screen presentation, and the “Controller” defines the way the user interface reacts to user input. You have data, and you put part of data into model, View renders and displays the data.

  49. Model/View Programming (3)

  50. Add headers Add in private section Model/View Programming (2)

More Related