Qt for S60
-
Upload
mark-wilcox -
Category
Technology
-
view
4.770 -
download
1
Transcript of Qt for S60
Sorcery LimitedSorcery Limited 22
What I’m Talking About What is Qt?What is Qt? Qt ModulesQt Modules Qt for S60Qt for S60 Technology PreviewsTechnology Previews Porting Qt applications to S60Porting Qt applications to S60
Example: CuteMazeExample: CuteMaze Porting other applications to Qt on S60Porting other applications to Qt on S60
Example: GDAL ViewerExample: GDAL Viewer
Sorcery LimitedSorcery Limited 33
What is Qt?
A cross-platform (soon to be free) application frameworkA cross-platform (soon to be free) application framework
Developed by Trolltech (bought by Nokia -> Qt Software)Developed by Trolltech (bought by Nokia -> Qt Software)
Aims to look native on every platform via GUI emulationAims to look native on every platform via GUI emulation
C++ code, highly modularC++ code, highly modular
Sorcery LimitedSorcery Limited 44
Qt Modules
QtCore QtGuiQtGui
QtNetworkQtNetwork QtOpenGLQtOpenGL
QtScriptQtScript QtSqlQtSql
QtSvgQtSvg QtWebKitQtWebKit
QtXml & QtXml & QtXmlPatternsQtXmlPatterns PhononPhonon
Sorcery LimitedSorcery Limited 55
QtCore A base object class with built-in event driven programming support and a A base object class with built-in event driven programming support and a
seamless object communication mechanism via signals and slotsseamless object communication mechanism via signals and slots Strings, arrays, characters, linked lists, stacks and queuesStrings, arrays, characters, linked lists, stacks and queues Atomic operations on integers and pointersAtomic operations on integers and pointers Guarded pointers (automatically zeroed when the object is destroyed)Guarded pointers (automatically zeroed when the object is destroyed) Date & time access and timersDate & time access and timers Files, streams and file system managementFiles, streams and file system management Containers – pairs, vectors, maps, hashes and setsContainers – pairs, vectors, maps, hashes and sets Threads, processes, mutexes, semaphores and shared memoryThreads, processes, mutexes, semaphores and shared memory Exceptions that can be transferred between threadsExceptions that can be transferred between threads Text handling and internationalization supportText handling and internationalization support Platform independent application settingsPlatform independent application settings Pattern matching using regular expressionsPattern matching using regular expressions Convenience functions for handling URLs and XMLConvenience functions for handling URLs and XML Support for loading libraries, plug-ins and resourcesSupport for loading libraries, plug-ins and resources Basic geometry via points, lines, sizes and rectanglesBasic geometry via points, lines, sizes and rectangles
Sorcery LimitedSorcery Limited 66
Signals & Slots Extension to C++ via code generated by the Qt Extension to C++ via code generated by the Qt
Meta-Object Compiler (moc)Meta-Object Compiler (moc) As part of class definition, declare signals that As part of class definition, declare signals that
object will emit and slots that are targets for object will emit and slots that are targets for signalssignals
A signal can also be connected to another signal A signal can also be connected to another signal so that emission of the first automatically causes so that emission of the first automatically causes the second to be emittedthe second to be emitted
Code examples…Code examples…
#include <QObject>class Cell : public QObject{ Q_OBJECT // This macro is required for all classes // that implement signals and slots public: Cell() { iValue = 0; } int value() const { return iValue; } public slots: void setValue(int value); signals: void valueChanged(int newValue); private: int iValue;};
void Cell::setValue(int value){ if (value != iValue) { iValue = value; emit valueChanged(value); }}
Sender sender;Receiver receiver;QObject::connect(&sender, SIGNAL(send(int)), &receiver, SLOT(receive(int)));
Sorcery LimitedSorcery Limited 77
QtGui QPainter class (graphics context style interface, QPainter class (graphics context style interface,
implementation in QPaintEngine subclasses) used to implementation in QPaintEngine subclasses) used to draw on any QPaintDevice instancedraw on any QPaintDevice instance
This includes QWidget – the base class for all widgetsThis includes QWidget – the base class for all widgets There are lots of useful widgets:There are lots of useful widgets:
Buttons, sliders and combo-boxesButtons, sliders and combo-boxes Windows, dialogs, forms and framesWindows, dialogs, forms and frames Scroll areas with scroll barsScroll areas with scroll bars Menus, tabs, toolbars and status barsMenus, tabs, toolbars and status bars Splash screens and progress barsSplash screens and progress bars Help search query and resultHelp search query and result Single and multi-line text editorsSingle and multi-line text editors List, table and tree viewsList, table and tree views CalendarCalendar
Sorcery LimitedSorcery Limited 99
QtNetwork Portable and simple network programming Portable and simple network programming
classes for:classes for: UDP, TCP, SSL and local socketsUDP, TCP, SSL and local sockets Key and certificate handling for secure Key and certificate handling for secure
communicationscommunications HTTP and FTP protocol implementationsHTTP and FTP protocol implementations Host address lookup by nameHost address lookup by name A managed request and response mechanismA managed request and response mechanism Proxies, authentication and cookie managementProxies, authentication and cookie management Local and remotely accessible (TCP) serversLocal and remotely accessible (TCP) servers
Sorcery LimitedSorcery Limited 1010
QtOpenGLAllows developers to combine a Qt UI with Allows developers to combine a Qt UI with
3D graphics rendered using OpenGL3D graphics rendered using OpenGLOpenGL ES used on embedded platformsOpenGL ES used on embedded platformsModule not yet available for Qt for S60Module not yet available for Qt for S60
Sorcery LimitedSorcery Limited 1111
QtScript Make your applications scriptable with Qt ScriptMake your applications scriptable with Qt Script Based on ECMAScript (JavaScript/JScript)Based on ECMAScript (JavaScript/JScript) QScriptEngine class used to evaluate scripts QScriptEngine class used to evaluate scripts
that are:that are: Typed by the userTyped by the user Loaded from diskLoaded from disk Downloaded from networkDownloaded from network
Can mix signals & slots between C++ and script Can mix signals & slots between C++ and script and create dynamic connections from script and create dynamic connections from script (moc at work again!)(moc at work again!)
Sorcery LimitedSorcery Limited 1212
QtSql Database integration moduleDatabase integration module 3-layered architecture3-layered architecture
Driver layerDriver layer SQL API layerSQL API layer UI layerUI layer
Provides model classes for use in a model/view Provides model classes for use in a model/view architecture in combination with data-aware architecture in combination with data-aware widgets from the QtGui modulewidgets from the QtGui module
Not yet available for Qt for S60 but will integrate Not yet available for Qt for S60 but will integrate with sqlitewith sqlite
Sorcery LimitedSorcery Limited 1313
QtSvgFor displaying Scalable Vector GraphicsFor displaying Scalable Vector GraphicsCurrently only the static features of SVG Currently only the static features of SVG
Tiny version 1.2 are supportedTiny version 1.2 are supportedSimply create a QSvgWidget and load an Simply create a QSvgWidget and load an
SVG file with itSVG file with it
Sorcery LimitedSorcery Limited 1414
QtWebKit WebKit integration moduleWebKit integration module New in Qt 4.4New in Qt 4.4 Download and display a web page in just 3 lines of code Download and display a web page in just 3 lines of code
with QWebView widget:with QWebView widget:QWebView *view = new QWebView(parent);view->load(QUrl("http://www.trolltech.com/"));view->show();
Provides bridge between JavaScript in the WebKit engine Provides bridge between JavaScript in the WebKit engine and QObject instances in Qt C++ code, very much like and QObject instances in Qt C++ code, very much like the QScript modulethe QScript module
Not yet available for Qt for S60 (although WebKit already Not yet available for Qt for S60 (although WebKit already used in S60)used in S60)
Sorcery LimitedSorcery Limited 1515
QtXml & QtXmlPatternsUtility classes for reading and writing XMLUtility classes for reading and writing XMLSAX & DOM based parsersSAX & DOM based parsersXQuery/XPath language supportXQuery/XPath language supportNot yet available in Qt for S60Not yet available in Qt for S60
Sorcery LimitedSorcery Limited 1616
PhononCross-platform multimedia frameworkCross-platform multimedia frameworkStarted as part of KDE and was then Started as part of KDE and was then
adopted into Qtadopted into QtActually just a common interface to Actually just a common interface to
various backends for different platformsvarious backends for different platformsHelix backend being developed for Qt for Helix backend being developed for Qt for
S60 – not yet availableS60 – not yet available
Sorcery LimitedSorcery Limited 1717
Qt for S60Port of Qt to S60Port of Qt to S60Currently in a “technology preview” stateCurrently in a “technology preview” stateNo commercial use allowed, GPL use and No commercial use allowed, GPL use and
evaluation only until it’s officially releasedevaluation only until it’s officially released Incomplete feature set and plenty of bugs Incomplete feature set and plenty of bugs
still to be fixedstill to be fixedActually fairly stable and usable already Actually fairly stable and usable already
(with a few major issues where things (with a few major issues where things aren’t implemented yet!)aren’t implemented yet!)
Sorcery LimitedSorcery Limited 1919
Qt for S60 Builds Qt uses a platform independent project file with Qt uses a platform independent project file with
a .pro extensiona .pro extension A Qt tool called qmake generates build files for A Qt tool called qmake generates build files for
each platform from the .pro fileseach platform from the .pro files So, on S60 the MMP, bld.inf and PKG files are So, on S60 the MMP, bld.inf and PKG files are
generated by qmake – they should not be editedgenerated by qmake – they should not be edited An extension makefile is also generated by An extension makefile is also generated by
qmake to support Qt extensions to C++ (e.g. qmake to support Qt extensions to C++ (e.g. moc, uic – Qt Designer support, rcc – resources)moc, uic – Qt Designer support, rcc – resources)
Sorcery LimitedSorcery Limited 2020
Implicit Sharing Symbian/S60 developers likely to be concerned Symbian/S60 developers likely to be concerned
by apparently high levels of stack usage in Qt by apparently high levels of stack usage in Qt applicationsapplications
It is higher than standard Symbian code but…It is higher than standard Symbian code but… Many objects, including QString, are implicitly shared Many objects, including QString, are implicitly shared
with copy-on-write semantics – only one copy of the with copy-on-write semantics – only one copy of the data exists (allocated on the heap) with shallow copy data exists (allocated on the heap) with shallow copy performed and a reference count incremented until a performed and a reference count incremented until a change is madechange is made
This allows passing of such objects as arguments and This allows passing of such objects as arguments and returning them from functions without a significant returning them from functions without a significant performance penaltyperformance penalty
Sorcery LimitedSorcery Limited 2121
Technology Previews Qt Software open source philosophy of release Qt Software open source philosophy of release
early and often – get developer/customer early and often – get developer/customer feedbackfeedback
Qt for S60 following this processQt for S60 following this process ““Pyramid” release in October – “just” QtCore, QtGui Pyramid” release in October – “just” QtCore, QtGui
and QtNetworkand QtNetwork ““Temple” release in December – added new modules, Temple” release in December – added new modules,
bugfixes and toolchain improvementsbugfixes and toolchain improvements ““Garden” release scheduled for Q109 – more Garden” release scheduled for Q109 – more
modules and S60 UI integration planned (Qt apps to modules and S60 UI integration planned (Qt apps to look like native apps)look like native apps)
Final release scheduled for Q309Final release scheduled for Q309
Sorcery LimitedSorcery Limited 2222
Porting Qt Applications to S60 Even though Qt is cross-platform, a new layout is Even though Qt is cross-platform, a new layout is
probably required for the smaller screen size of mobile probably required for the smaller screen size of mobile platformsplatforms
Some UI design may need changing to work with keypad Some UI design may need changing to work with keypad only input on many devicesonly input on many devices
We need to wait for the “Garden” release to know exactly We need to wait for the “Garden” release to know exactly how things are going to work (although we can get plenty how things are going to work (although we can get plenty of clues from the Windows CE port of Qt)of clues from the Windows CE port of Qt)
Known factors:Known factors: Applications will run “maximized” by default – you’ll still be able Applications will run “maximized” by default – you’ll still be able
to see the status bar and softkey areato see the status bar and softkey area QMenuBar for an application’s main window will map onto the QMenuBar for an application’s main window will map onto the
left softkey options menu (you can control which menu item also left softkey options menu (you can control which menu item also goes on the right (& centre?) softkeygoes on the right (& centre?) softkey
Sorcery LimitedSorcery Limited 2323
Example: CuteMazeApplications that are already scalable may Applications that are already scalable may
port extremely easilyport extremely easily
Sorcery LimitedSorcery Limited 2424
Porting Other Apps to Qt for S60
If you’re porting any application not If you’re porting any application not developed with Qt to S60 then it would be developed with Qt to S60 then it would be crazy not to consider Qt as a target:crazy not to consider Qt as a target:+ Simpler and easier to code for than native Simpler and easier to code for than native
S60 UI framework (Avkon)S60 UI framework (Avkon)+ Much more portable than other alternatives – Much more portable than other alternatives –
almost free porting after that to Windows almost free porting after that to Windows Mobile and embedded Linux devicesMobile and embedded Linux devices
- Slight performance penalty compared to Slight performance penalty compared to native Symbian codenative Symbian code
Sorcery LimitedSorcery Limited 2525
Example: GDAL ViewerSimple viewer application for multiple map Simple viewer application for multiple map
formats (learn about GDAL later)formats (learn about GDAL later)2-stage porting effort:2-stage porting effort:
First from Win32 to Qt on a Linux desktopFirst from Win32 to Qt on a Linux desktopSecond to Qt for S60Second to Qt for S60
Stage one took an experienced Qt Stage one took an experienced Qt developer with zero knowledge of Win32 developer with zero knowledge of Win32 ~5 hours~5 hours
Stage two took me 20 minutesStage two took me 20 minutes
Sorcery LimitedSorcery Limited 2727
Cool Qt Demo - WolfenQthttp://http://
labs.trolltech.com/blogs/category/labs/interlabs.trolltech.com/blogs/category/labs/internet/webkitnet/webkit//