• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Cross Platform Qt
 

Cross Platform Qt

on

  • 4,061 views

A presentation on cross platform development using Qt help on the second foss-sthlm meeting.

A presentation on cross platform development using Qt help on the second foss-sthlm meeting.

Statistics

Views

Total Views
4,061
Views on SlideShare
4,021
Embed Views
40

Actions

Likes
1
Downloads
0
Comments
0

4 Embeds 40

http://foss-sthlm.haxx.se 18
http://www.slideshare.net 17
http://www.lmodules.com 4
http://www.linkedin.com 1

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Cross Platform Qt Cross Platform Qt Presentation Transcript

    • Cross Platform Qt Johan Thelin
    • Quick Bio
      • Consultant – Qt/Linux
        • Development
        • Articles, whitepapers, etc
        • Training www.stf.se
      • Member of
      • Co-organizes FSCONS embedded November 5-7
    • The History of Qt
    • What is Qt
      • A framework written in C++
      • For creating portable application source code – one source, multiple platforms
      • Produces native applications
    • The History of Qt
      • Developed since 1991 by Eirik Chambe-Eng and Haavard Nord
      • Trolltech founded in 1994
      • Acquired by Nokia 2008
      • Nokia Qt Development Frameworks
    • The History of Qt
      • Originally Qt/X11 and Qt/Windows
        • X11 used Free Qt License, later QPL
        • Windows was closed source
      • Qt/OS X was released in 2001 (Qt 3.0)
        • OS X was closed source
      • 2005 all platforms released under GPL
      • 2009 all platforms released under LGPL
    • The History of Qt
      • The overall goal has been portable source code and the best framework
                • Code Less
                • Create More
                • Deploy Everywhere
    • The Architecture of Qt
    • The Modules of Qt QtGui QtSql QtNetwork QtWebKit QtSvg QtOpenGL QtOpenVG QtMultimedia QtScript QtXml QtXmlPatterns Phonon QtDBus QtTest
    • The Modules of Qt
      • Modules are libraries in themselves
      • Can be activated or disabled at compile time
      • Allows tweaking of feature set and footprint
      • As easy as CONFIG += sql network
      • All modules share the Qt API design
      • All modules fit together
    • Key Concepts
      • The QObject class makes Qt convenient
        • Simplified memory management
        • Signals and slots
        • Introspection
        • Properties
    • QObject – Memory Mgmt
      • Each QObject can have a parent
      • Parents delete all children upon destruction
      MyDialog::MyDialog(QWidget * parent ) : QDialog( parent ) { QPushButton *okButton = new QPushButton( this ); QPushButton *cancelButton = new QPushButton( this ); ... } MyWindow::useDialog() { MyDialog dlg(this); if(dlg.exec() == QDialog::Accepted) ... }
    • QObject – Signals and Slots
      • Dynamic calling of functions
        • One interface for all “callbacks”
        • Works seamless across thread boundaries
        • Creates re-usable components
      class QPushButton : ... { ... signals : void clicked(); ... }; class QListWidget : ... { ... public slots : void clear(); ... }; connect (button, SIGNAL(clicked()), list, SLOT(clear()));
    • QObject – Signals and Slots
      • Inside the button class
      • Signals and function pointer tables, etc are generated by the meta object compiler, moc
      • Invoked at compile time and generates additional vanilla C++ source code
      emit clicked();
    • QObject - Introspection
      • moc extracts more information, e.g. class names and inheritance
      • This enables introspection
        • Dynamic object creation, casting, method calling, etc
        • Great when creating language bindings
        • Makes RTTI work across library boundaries
    • QObject - Properties
      • QObject and moc also add support for properties, e.g.
      • Great when binding to dynamic languages
      • Great when serializing objects
      • Can be used to add extra information to existing classes. Useful in combination with visitor classes
      class QLabel : ... { Q_PROPERTY (QString text READ text WRITE setText ...) ... }
    • More Qt
      • The power of C++ combined with the flexibility and ease of dynamic languages
      • Qt is more
        • Great documentation
        • Large community
        • High quality code
        • etc
    • Qt Today
    • Examples of Qt in Use
      • KDE
      • Google Earth
      • Nokia N900
    • Available Qt Platforms Official Ports
      • X11
      • Windows
      • Mac OS X
      • Embedded Linux
      • Windows CE
      • Symbian
      • Maemo / MeeGo
      Other Ports
      • OpenSolaris
      • Haiku
      • OS/2
      • iPhone
      • Android
      • webOS
      • Kindle DX
      • QNX
      • wxWorks
    • Available Qt Bindings
      • C++
      • C# (.net)
      • Ada
      • Java
      • JavaScript
      • Lisp
      • Lua
      • Perl
      • PHP
      • Python
      • Ruby
      • etcetera
      • Qt is developed in C++
      • The QtScript module enables JavaScript integration
      • PyQt is very popular
      • The smoke bindings generator from KDE makes it easy to create more bindings
    • Qt Today
      • The core value and main objective still holds true: portable source code
      • The goal of Qt is to blend in everywhere
    • Portability Tips and Tricks
    • Portability - Interfaces QStyle QCommonStyle QMotifStyle QWindowStyle QS60Style QProxyStyle QCDEStyle QMacStyle QPlastiqueStyle QWindowsXPStyle QCleanlooksStyle QGtkStyle QWindowsVistaStyle
    • Portability - Interfaces
      • Not all custom widgets are style aware!
      void MyWidget::paintEvent(QPaintEvent *event) { QPainter painter(this); QStyleOptionFocusRect option; option.initFrom(this); style()->drawPrimitive (QStyle::PE_FrameFocusRect, &option, &painter, this); }
    • Portability - Backends ... QPainter QPaintEngine QRasterPaintEngine X11 Windows OpenGL SVG
    • Portability - Backends
      • The QPainter acquires a raster engine through the QPaintDevice interface implemented by all QWidget classes
      void MyWidget::paintEvent(QPaintEvent *event) { QPainter painter(this) ; QStyleOptionFocusRect option; option.initFrom(this); style()->drawPrimitive(QStyle::PE_FrameFocusRect, &option, &painter, this); }
    • Backends
      • For embedded Linux, there are a number of useful backends
        • QKbdDriverPlugin
        • QMouseDriverPlugin
        • QScreenDriverPlugin
      • For general use, there are even more
        • Accessibility, fonts, icons, image loading and saving, styles, codecs, etc
    • Portability - Hints
      • Qt uses flags for platform specific features. The flags are ignored when they are not valid
        • Qt::Drawer
        • Qt::Sheet
      • On X11, the window manager can be a factor as it handles the window decorations, e.g.
        • Qt::WindowMinimizeButtonHint
        • Qt::WindowSystemMenuHint
      Mac OS X specific dialogs, gives you an ordinary dialog or window on other platforms.
    • Portability - Hints
      • When hinting or using platform specifics – be aware of the limitations
      • Documentation: “ Indicates that the window is a Macintosh sheet. Since using a sheet implies window modality, the recommended way is to use QWidget::setWindowModality()... ”
      MyDialog::MyDialog(QWidget *parent) : QWidget(parent, Qt::Sheet ) { setWindowModality(Qt::WindowModal); ...
    • More Portability
      • Defines make it possible to write dedicated code for each platform
        • Q_OS_LINUX , Q_LITTLE_ENDIAN , etc
      • It is possible to hook into platform specific events
      • It is possible to tweak the Qt build system to link against different libraries on different platforms
      • It is possible to enable or disable individual classes to streamline Qt
      • ...
      bool QWidget::x11Event (XEvent *event)
    • Portability
      • In 99% of the cases no platform specific code is needed
      • As long as you stick to Qt APIs you do not have to worry about platforms – it just works
    • Thank you for your attention! [email_address]