Qt Programming on TI Processors


Published on

This presentation was made at TI Tech Days 1 Day Workshop in December 2009.

Published in: Technology, Art & Photos
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • Runtime charges apply when the Qt-based application is part of a joint hardware and software distribution and the main UI of the device is controlled by Qt.
  • Qt Programming on TI Processors

    1. 1. QT/E Workshop on TI Processors Dec 2009 Prabindh Sundareson ( [email_address] )
    2. 2. Agenda <ul><li>Introduction to QT </li></ul><ul><li>Fundamentals of QT </li></ul><ul><li>Setting up and building QT </li></ul><ul><ul><li>Exercise session </li></ul></ul><ul><li>Debugging QT </li></ul><ul><ul><li>Exercise session </li></ul></ul><ul><li>Building a real-world UI in QT </li></ul><ul><ul><li>Exercise session </li></ul></ul><ul><li>Performance of QT </li></ul><ul><li>Language support in QT </li></ul><ul><li>References </li></ul>
    3. 3. QT/E as an application framework <ul><li>As UI - Windowing system, various screen drivers </li></ul><ul><li>Touchscreen support </li></ul><ul><li>Supports 3D graphics (OpenGL ES), 2D graphics (SVG) </li></ul><ul><li>Support classes – Networking, Image decoders,XML, … </li></ul><ul><li>Deployment – Language translation </li></ul><ul><li>Source available under LGPL </li></ul><ul><li>Future – Web services … </li></ul>
    4. 4. Qt Roadmap <ul><li>Improved Optimization & Performance </li></ul><ul><li>Multi-touch & Gestures </li></ul><ul><ul><li>Enables user interaction with more than one finger, and combines sequential touch inputs to a ‘gesture’ </li></ul></ul><ul><li>OpenVG </li></ul><ul><ul><li>Provide Hooks for Hardware Acceleration </li></ul></ul><ul><li>3D Enablers </li></ul><ul><ul><li>Provide APIs to simplify creation of 3D applications with OpenGL, including math primitives for matrix multiplication, vectors, quaternions (client-side) and an API for vertex and fragment Shaders </li></ul></ul>
    5. 5. Qt License Options Commercial LGPL v. 2.1 GPL v. 3 License Cost License fee charged No cost No cost Must provide source code for changes to Qt No, modifications can be closed Source code must be provided Source code must be provided Can create proprietary application Yes—no obligation to disclose source code Yes, if dynamically linked to Qt library No, application is subject to the GPL Support Yes, with valid maintenance agreement Not included, available separately Not included, available separately Charge for Runtimes Yes—in some instances* No, distribution is royalty free No, distribution is royalty free
    6. 6. OMAP3530 Processor ARM ® Cortex ™ -A8 CPU L3/L4 Interconnect C64x+ ™ DSP and video accelerators (3525/3530 only) Peripherals Program/Data Storage System I 2 C x3 Serial Interfaces Display Subsystem Connectivity MMC/ SD/ SDIO x3 USB Host Controller x3 USB 2.0 HS OTG Controller GPMC SDRC UART x2 UART w/IRDA McBSP x5 McSPI x4 Timers GP x12 WDT x2 Image Pipe Parallel I/F Camera I/F POWERVR SGX™ Graphics (3515/3530 only) HDQ / 1-wire OMAP35x Processor 10 bit DAC Video Enc 10 bit DAC LCD Cont- roller
    7. 7. ARM9 Processors ARM9 Subsystem DSP Subsystem ARM 926EJ-S CPU 300 MHz C674x DSP Core 300 MHz Switched Central Resource (SCR) / EDMA Peripherals mDDR/ DDR2 16-bit Program/Data Storage I 2 C (2) Serial Interfaces Connectivity 64 bit WD Timer(1)/ GP Timer(3) System PWM (2) SATA UHPI USB2.0 OTG W/PHY UART (3) McASP (1) SPI (2) MMC/SD (2) L1P 16K L1D 16K L1P 32K L1D 32K L2 256K Video IN USB 1.1 W/PHY EMAC (MII/RMII) Async EMIF 16-bit LCD Controller OMAP-L138 uPP McBSP (2) 128KB RAM PDSP Subsystem 2x PDSP Core 150 MHz 4K+4K Prog 512+512 Data GPIOs GPIOs ECAP (3) EDMA3 (64ch)
    8. 8. Typical Applications <ul><li>Industrial Equipment HMI </li></ul><ul><li>Medical devices </li></ul><ul><li>Video Conferencing </li></ul><ul><li>Mobile phones - Maemo in Nokia N series </li></ul><ul><li>QT is an efficient framework built on C++ </li></ul>
    9. 9. Basics of QT
    10. 10. The QT Framework FB Cairo QT/E DirectFB Surface Managers (QScreen) X Window System/Mgrs (QWS, QPaintEngine) Application Framework (QApp, QWidget) HW Device (QScreen) QT for WinCE GDI DDr a w Win32/ Windowing System
    11. 11. Simple 6 Steps <ul><li>Steps to create UI: </li></ul><ul><ul><li>Design the UI in QT Designer </li></ul></ul><ul><ul><li>Add necessary event handlers in CPP file </li></ul></ul><ul><ul><li>Add necessary application level code </li></ul></ul><ul><ul><ul><li>Ex, Timers, Network stacks, Motor control, … </li></ul></ul></ul><ul><ul><li>Create .PRO file </li></ul></ul><ul><ul><li>Build, debug in QT Creator </li></ul></ul><ul><ul><li>Configure, build, install to target </li></ul></ul>
    12. 12. OOP Concepts in QT <ul><li>Inheritance (ex QGLWidget derived from QWidget .) </li></ul><ul><li>Templates (ex, Blit_* functions) </li></ul><ul><li>Design Patterns </li></ul><ul><li>Virtual Functions (ex, Paintevents) </li></ul><ul><li>Review virtual functions </li></ul><ul><ul><li>Visual Studio Project </li></ul></ul>
    13. 13. Basics of QT - Widgets
    14. 14. Basics of QT - Widgets <ul><li>QT UI framework is based on widgets </li></ul><ul><li>Widgets respond to UI events (key presses/mouse movements), and update their screen area </li></ul><ul><li>Each widget has a parent, that affects its behaviour </li></ul><ul><li>Window is a widget that is not embedded in a parent </li></ul>
    15. 15. Class Tree of GL/Widgets <ul><li>Allows 3D operations to be performed in a widget </li></ul><ul><li>As like any widget, QGLWidget operates on a target buffer </li></ul><ul><li>QGLWidget is implemented in srcopenglqgl.cpp </li></ul><ul><li>Override operations in QGLWidget::paintGL() </li></ul>
    16. 16. Event Handling Flow - PaintEvent
    17. 17. QPainter <ul><li>Working of QWidget::event() </li></ul><ul><ul><li>Handed down from QApplication, passes on to widget event handler </li></ul></ul><ul><ul><li>Srcguikernelqwidget.cpp </li></ul></ul><ul><ul><ul><li>case QEvent::Paint: </li></ul></ul></ul><ul><li>Handling paint events, why is the need to override ? </li></ul><ul><ul><li>Recall: Each window/widget is responsible for updating its own area </li></ul></ul>
    18. 18. Sample Painting flow <ul><ul><ul><li>void GLWidget::paintEvent(QPaintEvent *event) </li></ul></ul></ul><ul><ul><ul><ul><li>{ </li></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>QPainter painter; </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>painter.begin(this); //All widgets have a PaintDevice </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>painter.setRenderHint(QPainter::Antialiasing); </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>//rotate,draw, write text, all graphics operations </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>helper->paint(&painter, event, elapsed); </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>painter.end(); </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><li>} </li></ul></ul></ul></ul>
    19. 19. How does the draw happen ? <ul><ul><li>All drawings are converted to Vector paths !!!! </li></ul></ul><ul><ul><li>- Refer srcguipaintingqpaintengineex.cpp </li></ul></ul><ul><ul><li>void QPaintEngineEx::drawEllipse(const QRectF &r) </li></ul></ul><ul><ul><li>{ </li></ul></ul><ul><ul><ul><li>qreal pts[26]; // QPointF[13] without constructors... </li></ul></ul></ul><ul><ul><ul><li>union { </li></ul></ul></ul><ul><ul><ul><li>qreal *ptr; </li></ul></ul></ul><ul><ul><ul><li>QPointF *points; </li></ul></ul></ul><ul><ul><ul><li>} x; </li></ul></ul></ul><ul><ul><ul><li>x.ptr = pts; </li></ul></ul></ul><ul><ul><ul><li>int point_count = 0; </li></ul></ul></ul><ul><ul><ul><li>x.points[0] = qt_curves_for_arc(r, 0, -360, x.points + 1, &point_count); </li></ul></ul></ul><ul><ul><ul><li>QVectorPath vp((qreal *) pts, 13, qpaintengineex_ellipse_types, </li></ul></ul></ul><ul><ul><ul><li>QVectorPath::EllipseHint); </li></ul></ul></ul><ul><ul><ul><li>draw(vp); </li></ul></ul></ul><ul><ul><li>} </li></ul></ul>
    20. 20. QPaintEngine <ul><li>QPaintEngine is an abstraction between QPainter and QPaintdevice. </li></ul><ul><ul><li>OpenGL has its own Paint Engine for example, accessible through QGLWidget. </li></ul></ul><ul><ul><li>srcopenglqpaintengine_opengl.cpp </li></ul></ul><ul><li>QPainter can use QGLWidget as a paintdevice as it inherits QPaintDevice </li></ul><ul><li>Using OpenGL ES to accelerate regular widgets as well as compositing top-level windows with OpenGL ES are not currently supported </li></ul>
    21. 21. Painting Summary – for QT/E <ul><li>The QPaintEngine API provides paint engines for each window system and painting framework supported by Qt. In regards to Qt for Embedded, this also includes implementations for OpenGL ES versions 1.1 and 2.0, as well as OpenVG and DirectFB(Embedded Linux only). </li></ul><ul><li>Default implementation uses QRasterPaintEngine </li></ul>
    22. 22. Window Surfaces <ul><li>When a screen update is required, the server runs through all the top-level windows that intersect with the region that is about to be updated, and ensures that the associated clients have updated their memory buffer. Then the server uses the screen driver (represented by an instance of the QScreen class) to copy the content of the memory to the screen. </li></ul><ul><li>There are in fact two window surface instances for each top-level window; one used by the application when drawing a window, and another used by the server application to perform window compositing (using QScreenDriverPlugin) </li></ul>
    23. 23. QScreenDriverPlugin <ul><li>The screen driver encapsulates all the HW display functionality of the platform in QT/E </li></ul><ul><ul><li>Ex, Graphics HW like PowerVR, Linux FB </li></ul></ul><ul><li>All QT/E Window system implementations are in, </li></ul><ul><ul><li>Srcguiembedded folder </li></ul></ul><ul><li>Screen drivers for powervr, linuxfb, directfb, qvfb are supported </li></ul><ul><ul><ul><ul><li>srcpluginsgfxdriverspowervrpvreglscreenplugin.cpp </li></ul></ul></ul></ul><ul><ul><ul><ul><li>srcguiembeddedqscreen***.cpp </li></ul></ul></ul></ul><ul><li>PvrEglScreen is an implementation of QScreenDriverPlugin </li></ul><ul><li>The server uses the QScreenDriver plugin to copy content of the widget rendered memory to the display </li></ul><ul><li>How to set ? </li></ul><ul><ul><li>Set as env variable by QWS_DISPLAY=xxx </li></ul></ul><ul><ul><ul><li>ex. “powervr”, “LinuxFb” (default),… </li></ul></ul></ul>
    24. 24. Updating the Screen <ul><li>For each update, the server runs through all the top-level windows that intersect with the region that is about to be updated, </li></ul><ul><ul><li>To let the client widgets update their screen area (memory buffer). </li></ul></ul><ul><li>The server uses the screen driver to copy the content of the memory to the screen. </li></ul>
    25. 25. QGraphicsView <ul><li>The QGraphicsView class provides a widget for displaying the contents of a QGraphicsScene. </li></ul><ul><li>This provides a scrollable view model </li></ul><ul><li>By default, QGraphicsView provides a regular QWidget for the viewport widget. Can replace default by calling setViewport() with another widget type </li></ul><ul><li>To render using OpenGL, simply call setViewport(new QGLWidget). QGraphicsView takes ownership of the viewport widget. </li></ul>
    26. 26. 3D usage in QT <ul><li>#1 -- As a Widget paint device (QGLWidget) </li></ul><ul><ul><li>Allows native GL calls in widget, also does drawing of objects (ex Text) using OpenGL like other paint engines </li></ul></ul><ul><ul><li>Operates on widget client buffer </li></ul></ul><ul><ul><ul><li>Paint Engine for ES2.0 is at </li></ul></ul></ul><ul><ul><ul><ul><li>Srcopenglgl2paintengineexqpaintengineex_opengl2.cpp </li></ul></ul></ul></ul><ul><ul><ul><li>For ES1.1 is at, </li></ul></ul></ul><ul><ul><ul><ul><li>Srcopenglqpaintengine_opengl.cpp </li></ul></ul></ul></ul><ul><li>#2 -- As a screen driver (server paint device) set by QWS_DISPLAY </li></ul><ul><ul><li>operates on display buffer, through PVR2D </li></ul></ul><ul><ul><ul><li>PvrEglWindowSurface </li></ul></ul></ul><ul><ul><ul><ul><li>srcpluginsgfxdriverspvreglscreenpvreglwindowsurface.cpp </li></ul></ul></ul></ul>
    27. 27. QGraphicsView <ul><li>Because QGraphicsView inherits QWidget indirectly, it already provides the same drag and drop functionality that QWidget provides. In addition, as a convenience, the Graphics View framework provides drag and drop support for the scene, and for each and every item </li></ul><ul><li>QGraphicsView provides the view widget, which visualizes the contents of a scene. </li></ul><ul><li>You can attach several views to the same scene, to provide several viewports into the same data set. </li></ul><ul><li>QGraphicsScene provides the Graphics View scene </li></ul><ul><li>QGraphicsScene allows you to render parts of the scene into a paint device through the GraphicsScene::render () function </li></ul><ul><li>QGraphicsScene provides the Graphics View scene. </li></ul><ul><li>QGraphicsView::render (), on the other hand, is suitable for taking screenshots; its default behavior is to render the exact contents of the viewport using the provided painter. </li></ul>
    28. 28. QWidget and QGraphicsWidget Full modality support. Widget items do not support modality. Standard drag and drop framework. Graphics View provides a custom drag and drop framework, different from QWidget . A top-level widget's style defaults to QApplication::style A top-level item's style defaults to QGraphicsScene::style All widget attributes are supported. A subset of widget attributes are supported. QWidget is hidden by default until you call show (). The widget is already visible by default; you do not have to call show () to display the widget. QWidget uses integer geometry ( QPoint , QRect ). Coordinates and geometry are defined with qreals (doubles or floats, depending on the platform). QWidget QGraphicsWidget
    29. 29. Using SVG with QT <ul><li>QSVG uses QPainter paths to draw vector objects directly (without tessellation) </li></ul><ul><li>Using OpenGL as a backend, however, uses tessellation to render the triangle primitives </li></ul>
    30. 30. How does QTessellator work <ul><li>Uses a horizontal scanline </li></ul><ul><li>QTessellator calls addTrap() function to let application know of broken up trapezoids generated during scanning from top to bottom </li></ul><ul><li>Application has to store these, in order to draw them using OpenGL ES triangles </li></ul><ul><ul><li>qpaintengine_opengl.cpp </li></ul></ul>
    31. 31. Mouse Driver <ul><li>The mouse driver and the associated device can be specified using the QWS_MOUSE_PROTO environment variable, whose value must have the syntax type : device , where type is one of the supported drivers and device is the path to the device (e.g., QWS_MOUSE_PROTO=IntelliMouse:/dev/mouse ). Keyboards are handled similarly through the QWS_KEYBOARD environment variable </li></ul>
    32. 32. Creating accelerated Graphics Drivers <ul><li>Step 1: Create a Custom Screen (to accelerate copying to screen) </li></ul><ul><li>Step 2: Implement a Custom Raster Paint Engine (to accelerate the painting operations) </li></ul><ul><li>Step 3: Make the Paint Device Aware of Your Paint Engine </li></ul><ul><li>Step 4: Make the Window Surface Aware of Your Paint Device </li></ul><ul><li>Step 5: Enable Creation of an Instance of Your Window Surface </li></ul>
    33. 33. Accelerated Drivers on OMAP3 <ul><li>ARM-NEON instructions can be used to accelerate 2D rendering on OMAP3 </li></ul><ul><li>This will be released public in Jan 10 </li></ul>
    34. 34. Threads in QT <ul><li>Perform blocking/ time consuming activities in separate thread </li></ul><ul><ul><li>Use paintEvent() to trigger/consume the result of actions happening in parallel (ex. Upload next video frame) </li></ul></ul><ul><li>Use SIGNAL/SLOT to communicate between threads </li></ul><ul><ul><li>Ex – Mandelbrot example in </li></ul></ul><ul><ul><ul><li>Examplesmandelbrot </li></ul></ul></ul>
    35. 35. Using SIGNAL/SLOT <ul><li>Class myClass: public QThread </li></ul><ul><li>{ </li></ul><ul><li>Public: </li></ul><ul><li>… </li></ul><ul><li>signals: </li></ul><ul><li> void function1(const QImage &image, double scaleFactor); </li></ul><ul><li>}; </li></ul><ul><li>In thread code, </li></ul><ul><li>emit function1(image, scaleFactor); </li></ul>In Main application, define the actual function:: void myWidget::mainWidgetFunction(const QImage &image, double scaleFactor){} … And connect the signal and slot: connect(&thread, SIGNAL(mainWidgetFunction(const QImage &, double)), this, SLOT(function1(const QImage &, double)));
    36. 36. Creating Splash screen widgets <ul><li>Use QSplashScreen Widget to create startup screens before the main application starts </li></ul><ul><ul><li>Hides application startup delays </li></ul></ul>
    37. 37. Other useful application classes <ul><li>Networking </li></ul><ul><li>State Machine </li></ul><ul><li>Browser (Webkit based) </li></ul><ul><li>Media player (Phonon) </li></ul><ul><li>… </li></ul>
    38. 38. Setting up and building QT
    39. 39. Downloading the Source <ul><li>Download from Nokia/Trolltech website </li></ul><ul><ul><li>Ex, </li></ul></ul><ul><ul><ul><ul><li>http://ftp3.ie.freebsd.org/pub/trolltech/pub/qt/source/ </li></ul></ul></ul></ul><ul><li>For WinCE, </li></ul><ul><ul><li>http://qt.nokia.com/products/platform/qt-for-windows-ce </li></ul></ul>
    40. 40. Configuring QT/E for Linux <ul><li>Set toolchain paths (ex. PATH=..:$PATH) </li></ul><ul><li>Changes need to be made to this file (toolchain invoke) </li></ul><ul><ul><li>mkspecs/qws/linux-arm-g++/qmake.conf </li></ul></ul><ul><li>Create the configuration scripts </li></ul><ul><ul><li>./configure -embedded arm -little-endian -fast -D QT_QWS_CLIENTBLIT -depths 16,24,32 -xplatform qws/linux-arm-g++ -arch arm -no-xinerama -no-xkb -opengl es2 -plugin-gfx-powervr -D QT_NO_QWS_CURSOR -debug -no-webkit </li></ul></ul><ul><ul><ul><ul><li>In QT/E, the graphics system API is part of the QScreen plugin architecture, and hence “-graphicssystem” option is not supported </li></ul></ul></ul></ul><ul><li>Then “make” </li></ul>
    41. 41. Adding Touchscreen Support <ul><li>For TSlib on Linux </li></ul><ul><ul><li>First configure and build tslib then configure and build Qt with [-qt-mouse-tslib] option. </li></ul></ul><ul><li>http://doc.trolltech.com/4.5/qt-embedded-pointer.html </li></ul>
    42. 42. QT with DirectFB backend <ul><li>Define QT_CFLAGS_DIRECTFB and QT_LIBS_DIRECTFB </li></ul><ul><li>ex values would be: </li></ul><ul><li>QT_CFLAGS_DIRECTFB = -D_REENTRANT -I/usr/include/directfb </li></ul><ul><li>QT_LIBS_DIRECTFB = -ldirectfb -lfusion -ldirect -lpthread </li></ul>
    43. 43. Configuring QT/E for WinCE <ul><li>Open Visual Studio Command Prompt from platform debugger </li></ul><ul><li>Changes need to be made to this file </li></ul><ul><ul><li>mkspecs/qws/wince60standard-armv4i-msvc2005/qmake.conf </li></ul></ul><ul><li>Create the configuration scripts </li></ul><ul><ul><li>configure -platform win32-msvc2005 -fast -xplatform wince60standard-armv4i-msvc2005 -debug –no-webkit -no-openssl -no-cetest -no-iwmmxt -D _CRT_SECURE_NO_DEPRECATE </li></ul></ul><ul><ul><li>Then “nmake” </li></ul></ul>
    44. 44. Getting debug output <ul><li>QWarning, QDebug are enabled in –debug mode only </li></ul>
    45. 45. Debugging QT
    46. 46. Debugging QT <ul><li>http://qt.nokia.com/downloads/qt-creator-binary-for-linux-x11-32-bit </li></ul><ul><li>Needs GDB on Linux, and CDB for PC </li></ul>
    47. 47. QT Creator <ul><li>On Linux, compile GDB Server for target and run GDB on host </li></ul><ul><li>Then follow instructions </li></ul><ul><li>On Windows, use with x86 symbol set </li></ul><ul><li>Next -> Hands on debugging </li></ul><ul><ul><li>2D painting </li></ul></ul><ul><ul><li>Widgets </li></ul></ul>
    48. 48. Using QT-Creator <ul><li>Navigate to required folder, and open .pro file </li></ul><ul><li>“Set Build Configuration” </li></ul><ul><li>“Build Project” </li></ul><ul><li>Place breakpoints in source where needed </li></ul><ul><li>“Debug-> Start Debugging” </li></ul>
    49. 49. QWidget <ul><li>Examples etworkhttp </li></ul><ul><ul><li>SrcguikernelQWidget_win.cpp (on QWS_WIN), qwidget_qws.cpp (on QWS) </li></ul></ul><ul><ul><ul><ul><li>Void show_sys() </li></ul></ul></ul></ul><ul><ul><li>SrcguikernelQWidget.cpp </li></ul></ul><ul><ul><ul><ul><li>void QWidgetPrivate::showChildren(bool spontaneous) </li></ul></ul></ul></ul><ul><ul><li>SrcguipaintingQBackingstore.cpp </li></ul></ul><ul><ul><ul><ul><li>invalidateBuffer() </li></ul></ul></ul></ul><ul><ul><li>SrcguidialogsQDialog.cpp </li></ul></ul><ul><ul><ul><ul><li>eventLoop.exec() </li></ul></ul></ul></ul>
    50. 50. Building a real-world UI
    51. 51. UI Building 1 – Developing an Industrial UI with QT
    52. 52. QT Designer <ul><li>Can build for your platform – For example </li></ul><ul><li>> cd qt-everywhere-opensource-src-4.6.0-tp1 oolsdesigner </li></ul><ul><li>> nmake </li></ul><ul><li>Create a widget, or Form </li></ul><ul><ul><li>QTDesigner generates a .UI file </li></ul></ul>
    53. 53. Creating a Widget
    54. 54. Using QTdesigner generated files <ul><li>QTDesigner generates -> .UI file </li></ul><ul><li>Steps to create application from .UI file: </li></ul><ul><ul><li>Run “qmake” / “uic” to generate .h file from .UI file </li></ul></ul><ul><ul><ul><li>Alternately, use QUiLoader as below </li></ul></ul></ul><ul><ul><ul><ul><li>QWidget *formWidget = loader.load(&uifile..); </li></ul></ul></ul></ul><ul><ul><ul><li>QUiloader method allows application to create dynamic UIs using plugins loaded from the filesystem </li></ul></ul></ul><ul><ul><li>Create .PRO, .CPP files (next slide) </li></ul></ul><ul><ul><li>Run “nmake” (Windows) or “make” (Linux) to generate executable </li></ul></ul>
    55. 55. Creating required files HEADERS = mainwindow.h pieceslist.h puzzlewidget.h RESOURCES = puzzle.qrc SOURCES = main.cpp mainwindow.cpp pieceslist.cpp puzzlewidget.cpp # install target.path = $$[QT_INSTALL_EXAMPLES]/draganddrop/puzzle sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro *.jpg sources.path = $$[QT_INSTALL_EXAMPLES]/draganddrop/puzzle INSTALLS += target sources #include &quot;mainwindow.h“ int main(int argc, char *argv[]) { Q_INIT_RESOURCE(puzzle); QApplication app(argc, argv); MainWindow window; window.openImage(&quot;:/images/example.jpg&quot;); window.show(); return app.exec(); } For QT 4.6 protected: void paintEvent(QPaintEvent *event); … examplesdraganddroppuzzle .pro .cpp .h
    56. 56. Adding Event Handlers <ul><li>Event handlers are of the form, </li></ul><ul><ul><li>On_<Widgetname>_<SignalName> </li></ul></ul><ul><li>Ex, for “dial” widget, and “SliderReleased”, </li></ul><ul><ul><li>void Scaler::on_dial_sliderReleased(){} </li></ul></ul>
    57. 57. Transparency effects <ul><li>Transparency of a widget is set by </li></ul><ul><ul><li>widget->setWindowOpacity(fOpacity); </li></ul></ul>
    58. 58. UI #2 – Animation <ul><li>Appchooser </li></ul><ul><ul><li>examplesanimationappchooser </li></ul></ul>
    59. 59. QT Animation <ul><li>Use “QAnimationGroup” class </li></ul><ul><ul><li>Animation States – Running, Stopped, Paused </li></ul></ul><ul><ul><li>Changes the defined “property” – ex “geometry” </li></ul></ul><ul><ul><li>Defined by “Duration” </li></ul></ul><ul><ul><li>Runs for “loopCount” </li></ul></ul><ul><li>Sample Steps </li></ul><ul><ul><li>QPropertyAnimation animation(myWidget, &quot;geometry&quot;); </li></ul></ul><ul><ul><li>animation.setDuration(10000); </li></ul></ul><ul><ul><li>animation.setStartValue(QRect(0, 0, 100, 30)); animation.setEndValue(QRect(250, 250, 100, 30)); animation.start(); </li></ul></ul>
    60. 60. Performance of QT
    61. 61. Performance of QT <ul><li>CPU Resources used </li></ul><ul><li>How to optimise memory consumption </li></ul><ul><ul><li>QT/E takes about 10 MB (default package) </li></ul></ul>
    62. 62. Language Support in QT
    63. 63. Internationalisation <ul><li>QT supports Asian Languages </li></ul><ul><li>Use QString, tr during coding </li></ul><ul><li>Update Project files </li></ul><ul><li>Tools – QT Linguist, lupdate, lrelease </li></ul>
    64. 64. Conclusion <ul><li>Q&A </li></ul>
    65. 65. Queries <ul><li>Basics of QT </li></ul><ul><li>Is it possible to integrate flash object in qt ? </li></ul><ul><li>How can we integrated qt with webkit( / it is already integrated) and after integration what will be the performance </li></ul><ul><li>Overview of QT </li></ul><ul><li>Typically how the UI part interacts with the processing pieces – like separate processes, Various threads linked into Single executable etc </li></ul><ul><li>How does it allow Open GL constructs to be used within QT etc </li></ul>
    66. 66. References <ul><li>QT Documentation </li></ul><ul><ul><li>http://qt.nokia.com/ </li></ul></ul><ul><li>QT Creator documentation </li></ul><ul><ul><li>http://qt.nokia.com/doc/qtcreator-1.2/index.html </li></ul></ul><ul><li>Building QT on OMAP3 </li></ul><ul><ul><li>http://www.tiexpressdsp.com/index.php/Building_Qt </li></ul></ul>