SlideShare una empresa de Scribd logo
1 de 48
Descargar para leer sin conexión
Qt Quick – Hybrid models and Mobility
            SERIOUS ABOUT SOFTWARE
Timo Strömmer, Jan 10, 2010
                                        1
Contents
 •   QML-C++ hybrids

      • Exporting objects and properties into QML

      • Writing QML plug-ins

 •   Qt Mobility

      • Development environment setup

      • Integration with mobile peripherals

 •   QML-Web hybrids

      • Web browser integration

                                                    2
Simple C++ / QML integration example

C++/QML HYBRIDS


                                       3
Hybrid programs
 •   Hybrid programs get the benefit from both
     worlds

      • Ease of QML / script programming
           • See for example hellographics vs. HelloGraphicsQML

      • Power and flexibility of C++
           • Access to all services provided by the platform

           • C++ performance with larger data-sets




                                                                  4
QML/C++ hybrid
 •   A C++ GUI application may contain
     QDeclarativeView GUI components

      • Available for example via the GUI designer

      • Each runs it’s own declarative engine
            • qmlviewer also runs one

      • Resource-wise it’s not a good idea to run many
         views in a single program




                                                         5
QML/C++ hybrid
 •   QDeclarativeView has setSource function,
     which takes the URL of the QML file as
     parameter

      • Thus, can load also from web

 •   The QML files of the application can also be
     bundled into a resource file




                                                    6
QML/C++ exercise
 •   Create a new Qt GUI Project

      • Add a QDeclarativeView to the GUI form

      • Add QT += declarative to .pro file
            • Takes declarative QT module into use

      • Add a QML file to the project
            • Implement a GUI

      • Add a new Qt resource file to project
            • Add a / prefix

            • Add the QML file under the prefix



                                                     7
QML/C++ exercise
 •   Load the QML file from resource in the
     MainWindow constructor

 •   Build and run




                                              8
QML/C++ interaction
 •   To access the QML core from C++ side, the
     QDeclarativeView exposes a root context

      • QDeclarativeContext class

 •   A property can be set with
     setContextProperty function

      • Access normally by name in QML

                                           rectColor becomes
                                             property of root
                                              QML element




                                                                9
Exporting objects to QML
 •   Objects are registered with
     qmlRegisterType template function

      • Object class as template parameter

      • Function parameters:
           • Module name

           • Object version number (major, minor)

           • Name that is registered to QML runtime

                                                         Details about modules from:
                                           http://doc.trolltech.com/4.7/qdeclarativemodules.html




                                                                                               10
Using exported classes
 •   The exported classes can be used as any
     other QML component

      • The module needs to be imported




                                               11
QML object visibility
 •   Visibility at QML side

      • QObject properties become element properties
            • on<Property>Changed hook works if the NOTIFY signal
              is specified at C++ side

                 - Also note that C++ signal name doesn’t matter

      • QObject signals can be hooked with on<Signal>

      • QObject slots can be called as JS functions




                                                                    12
QML plug-in projects

HYBRID PROGRAMMING


                       13
QML plug-ins
 •   A plug-in allows QML runtime to load
     Qt/C++ libraries

      • Thus, QML/C++ hybrid code can be run via
        qmlviewer or some other QML launcher
        application




                                                   14
Quick start
 •   Create a QML extension plug-in project

      • Wizard generates one QObject-based class




                                                   15
QML plug-in basics
 •   A QML plug-in library must have a class
     which extends QDeclarativeExtensionPlugin

      • Wizard generates



      • The plugin has registerTypes function, which is
         used to define components that are exported to
         the QML runtime

            • Use qmlRegisterType and pass the uri to the module
              parameter




                                                                   16
QML plug-in basics
 •   The API used by QML runtime to load the
     plug-in is created via preprocessor macro

      • Q_EXPORT_PLUGIN if plug-in project and class
        names are the same (wizard does that)

      • Q_EXPORT_PLUGIN2 if names are different
           • See qmlpluginexample directory




                                                       17
QML plug-in basics
 •   The plug-in must define a qmldir file

      • Describes the name of the plug-in to load
           • libmobilityplugin.so on Linux

           • mobilityplugin.dll on Windows

           • Optionally may specify a sub-directory




                                                      18
Quick start continued
 •   Create a QML application project

      • Copy the qmldir file from the C++ plug-in into
         the applications plugin directory


 •   Edit the C++ plug-in .pro file

      • Add DESTDIR statement to point to the QML
         application directory




                                                         19
Quick start continued
 •   Switch to Release build

      • Fails with Debug libraries




 •   Build

      • The .so or .dll should be in the QML application
         directory where qmldir file also sits




                                                           20
Example plug-in
 •   See PluginExample and qmlpluginexample
     directories

      • Stores TextInput content into a file while user is
         typing

      • Uses QSettings API from Qt core
            • File in ~/.config/Symbio/QmlPluginExample.conf




                                                               21
More QML plug-in functions

HYBRID PROGRAMMING


                             22
Adding object properties
 •   Root QML context is also available to plug-
     in components

      • The QDeclarativeExtensionPlugin may
        implement initializeEngine function

      • QDeclarativeEngine which runs the QML code
        comes as function parameter




                                                     23
Running pure QML
 •   Sometimes it’s better to test in pure QML
     environment within qmlviewer

      • Speeds up GUI development

 •   Two ways

      • Use dummy objects to replace C++ types

      • Use dummydata directory to replace properties
        assigned from C++




                                                        24
Dummy types
•   To create a dummy type, add a
    corresponding QML component into the
    plugin subdirectory

     • Loaded if qmldir is missing




                                           25
Dummy properties
 •   qmlviewer supports loading of properties
     from dummydata subdirectory

      • The file name must equal the property name
        and thus starts with lower-case letter

      • Properties must be wrapped into QObject




                                                     26
Plug-in example
 •   Example in qmlpluginhooks and
     PluginHooks directories

      • Registers a QML type

      • Registers properties into root context

      • Uses dummy data for both




                                                 27
Setting up mobile development environment

MOBILE DEVELOPMENT


                                            28
Mobile development
 •   Mobile devices run different instruction set

      • C++ code needs to be cross-compiled

      • Qt SDK can build for N900 and Symbian

 •   Debugging on mobile difficult

      • A simulator environment provided by Nokia

 •   Focus on N900 in these slides




                                                    29
Mobile targets
 •   Three pre-installed targets in SDK

      • Maemo, Symbian, Simulator




                                          30
Qt Simulator
 •   Simulator target can be used to test N900
     or Symbian projects without real device




                                                 31
N900 environment
 •   Install Nokia Qt SDK

      • Or integrate MADDE to existing QtCreator

 •   Install required libraries on the device

 •   Setup usb network between devices

 •   Setup SSH connectivity

 •   Build and run



                                                   32
Environment setup
 •   N900 guide at:

      • http://doc.qt.nokia.com/qtcreator-
         2.0.1/creator-developing-maemo.html


 •   Additionally QML viewer and Qt Mobility

      • http://paazio.nanbudo.fi/tutorials/qt-quick/qt-
         quick-qml-viewer-installation-in-nokia-n900




                                                          33
N900 packaging
 •   QtCreator project options have an
     additional packaging step for Maemo
     projects




                                           34
N900 packaging
 •   QtCreator can only package applications

      • By default the project goes to /usr/local/bin

      • QML must be packaged into project resources

 •   Pure QML projects must be deployed by
     different means

      • For example memory card copy

      • See also http://qml.haltu.fi/




                                                        35
N900 packaging
 •   For plug-in projects, just disable packaging

      • You’ll still get the library .so
            • Copy to device into project directory

      • Note that you cannot run from memory card




                                                      Cannot be removed




                                                                          36
N900 packaging notes
 •   Mainly for own internal testing

      • No applications menu integration etc.
           • N900 based on Hildon UI framework

      • Better wait for MeeGo and next Qt SDK

 •   Also note that MeeGo uses different
     packaging mechanism

      • Debian in Maemo, RPM in MeeGo




                                                 37
Overview of the mobility API’s

QT MOBILITY


                                 38
Qt Mobility API’s
 •   List of API’s in Qt Mobility 1.1

      • http://qt.nokia.com/products/qt-
         addons/mobility


 •   Pre-built libraries in SDK

      • But not the latest 1.1 version
            • Missing some libraries and QML integration

      • Can be tested in Simulator

      • To get latest, you’ll need to build from sources



                                                           39
Qt Mobility API’s
 •   Mobility API’s are enabled via
     project file

      • CONFIG += mobility

      • MOBILITY = <modules to use>

 •   Example in n900test directory

      • For some reason the qmllocation
         project refuses to work




                                          40
Qt Mobility API’s




                    41
Qt Mobility API’s
 •   SDK comes with older libraries

      • So, check what’s in there

      •   <creator-path>/Simulator/QtMobility/gcc/include




                                                            42
QML / Web hybrids

HYBRID PROGRAMMING


                     43
Web browser integration
 •   QML has WebView component

      • Was used in n900test example to load map

      • Found from QtWebKit 1.0 module

 •   Basic properties

      • url specifies the web page to display

      • preferredWidth and preferredHeight to control
         the displayed web page size

      • Wrap into Flickable to enable scrolling
            • Still no scrollbars…

                                                        44
Web browser integration
 •   WebView provides action objects for web
     page navigation

      • back, forward, reload and stop

      • Actions can be triggered from script

 •   Basic hook signals

      • onLoadStarted, onLoadFinished, onLoadFailed

      • onAlert




                                                      45
Web browser integration
 •   QML and web scripts may interact with
     each other

      • evaluateJavaScript function runs script code in
         the context of the web browser

      • javascriptWindowObjects property registers QML
         objects as properties of the web window

            • WebView.windowObjectName attached property
               defines the name visible to browser

            • Functions of the object can be called via browser script


 •   Example in WebHybrid directory


                                                                         46
QUESTIONS?


             47
48

Más contenido relacionado

La actualidad más candente

Qt for beginners part 4 doing more
Qt for beginners part 4   doing moreQt for beginners part 4   doing more
Qt for beginners part 4 doing moreICS
 
Qt for Python
Qt for PythonQt for Python
Qt for PythonICS
 
Intro to QML / Declarative UI
Intro to QML / Declarative UIIntro to QML / Declarative UI
Intro to QML / Declarative UIOpenBossa
 
Best Practices in Qt Quick/QML - Part III
Best Practices in Qt Quick/QML - Part IIIBest Practices in Qt Quick/QML - Part III
Best Practices in Qt Quick/QML - Part IIIICS
 
QVariant, QObject — Qt's not just for GUI development
QVariant, QObject — Qt's not just for GUI developmentQVariant, QObject — Qt's not just for GUI development
QVariant, QObject — Qt's not just for GUI developmentICS
 
Best Practices in Qt Quick/QML - Part 3
Best Practices in Qt Quick/QML - Part 3Best Practices in Qt Quick/QML - Part 3
Best Practices in Qt Quick/QML - Part 3ICS
 
Basics of Model/View Qt programming
Basics of Model/View Qt programmingBasics of Model/View Qt programming
Basics of Model/View Qt programmingICS
 
Qt for beginners part 2 widgets
Qt for beginners part 2   widgetsQt for beginners part 2   widgets
Qt for beginners part 2 widgetsICS
 
Best Practices in Qt Quick/QML - Part 2
Best Practices in Qt Quick/QML - Part 2Best Practices in Qt Quick/QML - Part 2
Best Practices in Qt Quick/QML - Part 2Janel Heilbrunn
 
Qt on Real Time Operating Systems
Qt on Real Time Operating SystemsQt on Real Time Operating Systems
Qt on Real Time Operating Systemsaccount inactive
 
下午3 intel fenghaitao_mee_go api and application development
下午3 intel fenghaitao_mee_go api and application development下午3 intel fenghaitao_mee_go api and application development
下午3 intel fenghaitao_mee_go api and application developmentcsdnmobile
 
[Webinar] QtSerialBus: Using Modbus and CAN bus with Qt
[Webinar] QtSerialBus: Using Modbus and CAN bus with Qt[Webinar] QtSerialBus: Using Modbus and CAN bus with Qt
[Webinar] QtSerialBus: Using Modbus and CAN bus with QtICS
 
Lockless Producer Consumer Threads: Asynchronous Communications Made Easy
Lockless Producer Consumer Threads: Asynchronous Communications Made EasyLockless Producer Consumer Threads: Asynchronous Communications Made Easy
Lockless Producer Consumer Threads: Asynchronous Communications Made EasyICS
 
In-Depth Model/View with QML
In-Depth Model/View with QMLIn-Depth Model/View with QML
In-Depth Model/View with QMLICS
 
Best Practices in Qt Quick/QML - Part 1 of 4
Best Practices in Qt Quick/QML - Part 1 of 4Best Practices in Qt Quick/QML - Part 1 of 4
Best Practices in Qt Quick/QML - Part 1 of 4ICS
 
Meet the Widgets: Another Way to Implement UI
Meet the Widgets: Another Way to Implement UIMeet the Widgets: Another Way to Implement UI
Meet the Widgets: Another Way to Implement UIICS
 
Fun with QML
Fun with QMLFun with QML
Fun with QMLICS
 

La actualidad más candente (20)

Qt for beginners part 4 doing more
Qt for beginners part 4   doing moreQt for beginners part 4   doing more
Qt for beginners part 4 doing more
 
Qt for Python
Qt for PythonQt for Python
Qt for Python
 
Intro to QML / Declarative UI
Intro to QML / Declarative UIIntro to QML / Declarative UI
Intro to QML / Declarative UI
 
Best Practices in Qt Quick/QML - Part III
Best Practices in Qt Quick/QML - Part IIIBest Practices in Qt Quick/QML - Part III
Best Practices in Qt Quick/QML - Part III
 
QVariant, QObject — Qt's not just for GUI development
QVariant, QObject — Qt's not just for GUI developmentQVariant, QObject — Qt's not just for GUI development
QVariant, QObject — Qt's not just for GUI development
 
Best Practices in Qt Quick/QML - Part 3
Best Practices in Qt Quick/QML - Part 3Best Practices in Qt Quick/QML - Part 3
Best Practices in Qt Quick/QML - Part 3
 
Basics of Model/View Qt programming
Basics of Model/View Qt programmingBasics of Model/View Qt programming
Basics of Model/View Qt programming
 
Qt for beginners part 2 widgets
Qt for beginners part 2   widgetsQt for beginners part 2   widgets
Qt for beginners part 2 widgets
 
Best Practices in Qt Quick/QML - Part 2
Best Practices in Qt Quick/QML - Part 2Best Practices in Qt Quick/QML - Part 2
Best Practices in Qt Quick/QML - Part 2
 
Qt on Real Time Operating Systems
Qt on Real Time Operating SystemsQt on Real Time Operating Systems
Qt on Real Time Operating Systems
 
Qt Application Programming with C++ - Part 1
Qt Application Programming with C++ - Part 1Qt Application Programming with C++ - Part 1
Qt Application Programming with C++ - Part 1
 
下午3 intel fenghaitao_mee_go api and application development
下午3 intel fenghaitao_mee_go api and application development下午3 intel fenghaitao_mee_go api and application development
下午3 intel fenghaitao_mee_go api and application development
 
[Webinar] QtSerialBus: Using Modbus and CAN bus with Qt
[Webinar] QtSerialBus: Using Modbus and CAN bus with Qt[Webinar] QtSerialBus: Using Modbus and CAN bus with Qt
[Webinar] QtSerialBus: Using Modbus and CAN bus with Qt
 
Lockless Producer Consumer Threads: Asynchronous Communications Made Easy
Lockless Producer Consumer Threads: Asynchronous Communications Made EasyLockless Producer Consumer Threads: Asynchronous Communications Made Easy
Lockless Producer Consumer Threads: Asynchronous Communications Made Easy
 
In-Depth Model/View with QML
In-Depth Model/View with QMLIn-Depth Model/View with QML
In-Depth Model/View with QML
 
Qt 5 - C++ and Widgets
Qt 5 - C++ and WidgetsQt 5 - C++ and Widgets
Qt 5 - C++ and Widgets
 
Best Practices in Qt Quick/QML - Part 1 of 4
Best Practices in Qt Quick/QML - Part 1 of 4Best Practices in Qt Quick/QML - Part 1 of 4
Best Practices in Qt Quick/QML - Part 1 of 4
 
Meet the Widgets: Another Way to Implement UI
Meet the Widgets: Another Way to Implement UIMeet the Widgets: Another Way to Implement UI
Meet the Widgets: Another Way to Implement UI
 
Qt Application Programming with C++ - Part 2
Qt Application Programming with C++ - Part 2Qt Application Programming with C++ - Part 2
Qt Application Programming with C++ - Part 2
 
Fun with QML
Fun with QMLFun with QML
Fun with QML
 

Similar a QtQuick Day 4

Plasmaquick Workshop - FISL 13
Plasmaquick Workshop - FISL 13Plasmaquick Workshop - FISL 13
Plasmaquick Workshop - FISL 13Daker Fernandes
 
Scalable Spark deployment using Kubernetes
Scalable Spark deployment using KubernetesScalable Spark deployment using Kubernetes
Scalable Spark deployment using Kubernetesdatamantra
 
Continuous Deployment with Kubernetes, Docker and GitLab CI
Continuous Deployment with Kubernetes, Docker and GitLab CIContinuous Deployment with Kubernetes, Docker and GitLab CI
Continuous Deployment with Kubernetes, Docker and GitLab CIalexanderkiel
 
Simulating Production with Clocker
Simulating Production with ClockerSimulating Production with Clocker
Simulating Production with ClockerAndrew Kennedy
 
CD in kubernetes using helm and ksonnet. Stas Kolenkin
CD in kubernetes using helm and ksonnet. Stas KolenkinCD in kubernetes using helm and ksonnet. Stas Kolenkin
CD in kubernetes using helm and ksonnet. Stas KolenkinDataArt
 
Introduction to Kubernetes Workshop
Introduction to Kubernetes WorkshopIntroduction to Kubernetes Workshop
Introduction to Kubernetes WorkshopBob Killen
 
Kubernetes-Presentation-Syed-Murtaza-Hassan
Kubernetes-Presentation-Syed-Murtaza-HassanKubernetes-Presentation-Syed-Murtaza-Hassan
Kubernetes-Presentation-Syed-Murtaza-HassanSyed Murtaza Hassan
 
Mihai Criveti - PyCon Ireland - Automate Everything
Mihai Criveti - PyCon Ireland - Automate EverythingMihai Criveti - PyCon Ireland - Automate Everything
Mihai Criveti - PyCon Ireland - Automate EverythingMihai Criveti
 
Enhance Your Kubernetes CI/CD Pipelines With GitLab & Open Source
Enhance Your Kubernetes CI/CD Pipelines With GitLab & Open SourceEnhance Your Kubernetes CI/CD Pipelines With GitLab & Open Source
Enhance Your Kubernetes CI/CD Pipelines With GitLab & Open SourceNico Meisenzahl
 
Pydata 2020 containers meetup
Pydata  2020 containers meetup Pydata  2020 containers meetup
Pydata 2020 containers meetup Walid Shaari
 
Using Clocker with Project Calico - Running Production Workloads in the Cloud
Using Clocker with Project Calico - Running Production Workloads in the CloudUsing Clocker with Project Calico - Running Production Workloads in the Cloud
Using Clocker with Project Calico - Running Production Workloads in the CloudAndrew Kennedy
 
Building Cloud-Native Applications with Kubernetes, Helm and Kubeless
Building Cloud-Native Applications with Kubernetes, Helm and KubelessBuilding Cloud-Native Applications with Kubernetes, Helm and Kubeless
Building Cloud-Native Applications with Kubernetes, Helm and KubelessBitnami
 
K8s in 3h - Kubernetes Fundamentals Training
K8s in 3h - Kubernetes Fundamentals TrainingK8s in 3h - Kubernetes Fundamentals Training
K8s in 3h - Kubernetes Fundamentals TrainingPiotr Perzyna
 
Introduction kubernetes 2017_12_24
Introduction kubernetes 2017_12_24Introduction kubernetes 2017_12_24
Introduction kubernetes 2017_12_24Sam Zheng
 
Deploying NGINX Plus & Kubernetes on Google Cloud Platform
Deploying NGINX Plus & Kubernetes on Google Cloud PlatformDeploying NGINX Plus & Kubernetes on Google Cloud Platform
Deploying NGINX Plus & Kubernetes on Google Cloud PlatformNGINX, Inc.
 

Similar a QtQuick Day 4 (20)

Plasmaquick Workshop - FISL 13
Plasmaquick Workshop - FISL 13Plasmaquick Workshop - FISL 13
Plasmaquick Workshop - FISL 13
 
Scalable Spark deployment using Kubernetes
Scalable Spark deployment using KubernetesScalable Spark deployment using Kubernetes
Scalable Spark deployment using Kubernetes
 
Continuous Deployment with Kubernetes, Docker and GitLab CI
Continuous Deployment with Kubernetes, Docker and GitLab CIContinuous Deployment with Kubernetes, Docker and GitLab CI
Continuous Deployment with Kubernetes, Docker and GitLab CI
 
Simulating Production with Clocker
Simulating Production with ClockerSimulating Production with Clocker
Simulating Production with Clocker
 
CD in kubernetes using helm and ksonnet. Stas Kolenkin
CD in kubernetes using helm and ksonnet. Stas KolenkinCD in kubernetes using helm and ksonnet. Stas Kolenkin
CD in kubernetes using helm and ksonnet. Stas Kolenkin
 
Introduction to Kubernetes Workshop
Introduction to Kubernetes WorkshopIntroduction to Kubernetes Workshop
Introduction to Kubernetes Workshop
 
Kubernetes-Presentation-Syed-Murtaza-Hassan
Kubernetes-Presentation-Syed-Murtaza-HassanKubernetes-Presentation-Syed-Murtaza-Hassan
Kubernetes-Presentation-Syed-Murtaza-Hassan
 
Mihai Criveti - PyCon Ireland - Automate Everything
Mihai Criveti - PyCon Ireland - Automate EverythingMihai Criveti - PyCon Ireland - Automate Everything
Mihai Criveti - PyCon Ireland - Automate Everything
 
Enhance Your Kubernetes CI/CD Pipelines With GitLab & Open Source
Enhance Your Kubernetes CI/CD Pipelines With GitLab & Open SourceEnhance Your Kubernetes CI/CD Pipelines With GitLab & Open Source
Enhance Your Kubernetes CI/CD Pipelines With GitLab & Open Source
 
Kubernetes-Meetup
Kubernetes-MeetupKubernetes-Meetup
Kubernetes-Meetup
 
Better code, faster with kubernetes in google cloud
Better code, faster with kubernetes in google cloudBetter code, faster with kubernetes in google cloud
Better code, faster with kubernetes in google cloud
 
Pydata 2020 containers meetup
Pydata  2020 containers meetup Pydata  2020 containers meetup
Pydata 2020 containers meetup
 
Kubernetes
KubernetesKubernetes
Kubernetes
 
Quick introduction to Kubernetes
Quick introduction to KubernetesQuick introduction to Kubernetes
Quick introduction to Kubernetes
 
Using Clocker with Project Calico - Running Production Workloads in the Cloud
Using Clocker with Project Calico - Running Production Workloads in the CloudUsing Clocker with Project Calico - Running Production Workloads in the Cloud
Using Clocker with Project Calico - Running Production Workloads in the Cloud
 
Building Cloud-Native Applications with Kubernetes, Helm and Kubeless
Building Cloud-Native Applications with Kubernetes, Helm and KubelessBuilding Cloud-Native Applications with Kubernetes, Helm and Kubeless
Building Cloud-Native Applications with Kubernetes, Helm and Kubeless
 
K8s in 3h - Kubernetes Fundamentals Training
K8s in 3h - Kubernetes Fundamentals TrainingK8s in 3h - Kubernetes Fundamentals Training
K8s in 3h - Kubernetes Fundamentals Training
 
Introduction kubernetes 2017_12_24
Introduction kubernetes 2017_12_24Introduction kubernetes 2017_12_24
Introduction kubernetes 2017_12_24
 
Deploying NGINX Plus & Kubernetes on Google Cloud Platform
Deploying NGINX Plus & Kubernetes on Google Cloud PlatformDeploying NGINX Plus & Kubernetes on Google Cloud Platform
Deploying NGINX Plus & Kubernetes on Google Cloud Platform
 
141204 upload
141204 upload141204 upload
141204 upload
 

Último

Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 

Último (20)

Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 

QtQuick Day 4

  • 1. Qt Quick – Hybrid models and Mobility SERIOUS ABOUT SOFTWARE Timo Strömmer, Jan 10, 2010 1
  • 2. Contents • QML-C++ hybrids • Exporting objects and properties into QML • Writing QML plug-ins • Qt Mobility • Development environment setup • Integration with mobile peripherals • QML-Web hybrids • Web browser integration 2
  • 3. Simple C++ / QML integration example C++/QML HYBRIDS 3
  • 4. Hybrid programs • Hybrid programs get the benefit from both worlds • Ease of QML / script programming • See for example hellographics vs. HelloGraphicsQML • Power and flexibility of C++ • Access to all services provided by the platform • C++ performance with larger data-sets 4
  • 5. QML/C++ hybrid • A C++ GUI application may contain QDeclarativeView GUI components • Available for example via the GUI designer • Each runs it’s own declarative engine • qmlviewer also runs one • Resource-wise it’s not a good idea to run many views in a single program 5
  • 6. QML/C++ hybrid • QDeclarativeView has setSource function, which takes the URL of the QML file as parameter • Thus, can load also from web • The QML files of the application can also be bundled into a resource file 6
  • 7. QML/C++ exercise • Create a new Qt GUI Project • Add a QDeclarativeView to the GUI form • Add QT += declarative to .pro file • Takes declarative QT module into use • Add a QML file to the project • Implement a GUI • Add a new Qt resource file to project • Add a / prefix • Add the QML file under the prefix 7
  • 8. QML/C++ exercise • Load the QML file from resource in the MainWindow constructor • Build and run 8
  • 9. QML/C++ interaction • To access the QML core from C++ side, the QDeclarativeView exposes a root context • QDeclarativeContext class • A property can be set with setContextProperty function • Access normally by name in QML rectColor becomes property of root QML element 9
  • 10. Exporting objects to QML • Objects are registered with qmlRegisterType template function • Object class as template parameter • Function parameters: • Module name • Object version number (major, minor) • Name that is registered to QML runtime Details about modules from: http://doc.trolltech.com/4.7/qdeclarativemodules.html 10
  • 11. Using exported classes • The exported classes can be used as any other QML component • The module needs to be imported 11
  • 12. QML object visibility • Visibility at QML side • QObject properties become element properties • on<Property>Changed hook works if the NOTIFY signal is specified at C++ side - Also note that C++ signal name doesn’t matter • QObject signals can be hooked with on<Signal> • QObject slots can be called as JS functions 12
  • 13. QML plug-in projects HYBRID PROGRAMMING 13
  • 14. QML plug-ins • A plug-in allows QML runtime to load Qt/C++ libraries • Thus, QML/C++ hybrid code can be run via qmlviewer or some other QML launcher application 14
  • 15. Quick start • Create a QML extension plug-in project • Wizard generates one QObject-based class 15
  • 16. QML plug-in basics • A QML plug-in library must have a class which extends QDeclarativeExtensionPlugin • Wizard generates • The plugin has registerTypes function, which is used to define components that are exported to the QML runtime • Use qmlRegisterType and pass the uri to the module parameter 16
  • 17. QML plug-in basics • The API used by QML runtime to load the plug-in is created via preprocessor macro • Q_EXPORT_PLUGIN if plug-in project and class names are the same (wizard does that) • Q_EXPORT_PLUGIN2 if names are different • See qmlpluginexample directory 17
  • 18. QML plug-in basics • The plug-in must define a qmldir file • Describes the name of the plug-in to load • libmobilityplugin.so on Linux • mobilityplugin.dll on Windows • Optionally may specify a sub-directory 18
  • 19. Quick start continued • Create a QML application project • Copy the qmldir file from the C++ plug-in into the applications plugin directory • Edit the C++ plug-in .pro file • Add DESTDIR statement to point to the QML application directory 19
  • 20. Quick start continued • Switch to Release build • Fails with Debug libraries • Build • The .so or .dll should be in the QML application directory where qmldir file also sits 20
  • 21. Example plug-in • See PluginExample and qmlpluginexample directories • Stores TextInput content into a file while user is typing • Uses QSettings API from Qt core • File in ~/.config/Symbio/QmlPluginExample.conf 21
  • 22. More QML plug-in functions HYBRID PROGRAMMING 22
  • 23. Adding object properties • Root QML context is also available to plug- in components • The QDeclarativeExtensionPlugin may implement initializeEngine function • QDeclarativeEngine which runs the QML code comes as function parameter 23
  • 24. Running pure QML • Sometimes it’s better to test in pure QML environment within qmlviewer • Speeds up GUI development • Two ways • Use dummy objects to replace C++ types • Use dummydata directory to replace properties assigned from C++ 24
  • 25. Dummy types • To create a dummy type, add a corresponding QML component into the plugin subdirectory • Loaded if qmldir is missing 25
  • 26. Dummy properties • qmlviewer supports loading of properties from dummydata subdirectory • The file name must equal the property name and thus starts with lower-case letter • Properties must be wrapped into QObject 26
  • 27. Plug-in example • Example in qmlpluginhooks and PluginHooks directories • Registers a QML type • Registers properties into root context • Uses dummy data for both 27
  • 28. Setting up mobile development environment MOBILE DEVELOPMENT 28
  • 29. Mobile development • Mobile devices run different instruction set • C++ code needs to be cross-compiled • Qt SDK can build for N900 and Symbian • Debugging on mobile difficult • A simulator environment provided by Nokia • Focus on N900 in these slides 29
  • 30. Mobile targets • Three pre-installed targets in SDK • Maemo, Symbian, Simulator 30
  • 31. Qt Simulator • Simulator target can be used to test N900 or Symbian projects without real device 31
  • 32. N900 environment • Install Nokia Qt SDK • Or integrate MADDE to existing QtCreator • Install required libraries on the device • Setup usb network between devices • Setup SSH connectivity • Build and run 32
  • 33. Environment setup • N900 guide at: • http://doc.qt.nokia.com/qtcreator- 2.0.1/creator-developing-maemo.html • Additionally QML viewer and Qt Mobility • http://paazio.nanbudo.fi/tutorials/qt-quick/qt- quick-qml-viewer-installation-in-nokia-n900 33
  • 34. N900 packaging • QtCreator project options have an additional packaging step for Maemo projects 34
  • 35. N900 packaging • QtCreator can only package applications • By default the project goes to /usr/local/bin • QML must be packaged into project resources • Pure QML projects must be deployed by different means • For example memory card copy • See also http://qml.haltu.fi/ 35
  • 36. N900 packaging • For plug-in projects, just disable packaging • You’ll still get the library .so • Copy to device into project directory • Note that you cannot run from memory card Cannot be removed 36
  • 37. N900 packaging notes • Mainly for own internal testing • No applications menu integration etc. • N900 based on Hildon UI framework • Better wait for MeeGo and next Qt SDK • Also note that MeeGo uses different packaging mechanism • Debian in Maemo, RPM in MeeGo 37
  • 38. Overview of the mobility API’s QT MOBILITY 38
  • 39. Qt Mobility API’s • List of API’s in Qt Mobility 1.1 • http://qt.nokia.com/products/qt- addons/mobility • Pre-built libraries in SDK • But not the latest 1.1 version • Missing some libraries and QML integration • Can be tested in Simulator • To get latest, you’ll need to build from sources 39
  • 40. Qt Mobility API’s • Mobility API’s are enabled via project file • CONFIG += mobility • MOBILITY = <modules to use> • Example in n900test directory • For some reason the qmllocation project refuses to work 40
  • 42. Qt Mobility API’s • SDK comes with older libraries • So, check what’s in there • <creator-path>/Simulator/QtMobility/gcc/include 42
  • 43. QML / Web hybrids HYBRID PROGRAMMING 43
  • 44. Web browser integration • QML has WebView component • Was used in n900test example to load map • Found from QtWebKit 1.0 module • Basic properties • url specifies the web page to display • preferredWidth and preferredHeight to control the displayed web page size • Wrap into Flickable to enable scrolling • Still no scrollbars… 44
  • 45. Web browser integration • WebView provides action objects for web page navigation • back, forward, reload and stop • Actions can be triggered from script • Basic hook signals • onLoadStarted, onLoadFinished, onLoadFailed • onAlert 45
  • 46. Web browser integration • QML and web scripts may interact with each other • evaluateJavaScript function runs script code in the context of the web browser • javascriptWindowObjects property registers QML objects as properties of the web window • WebView.windowObjectName attached property defines the name visible to browser • Functions of the object can be called via browser script • Example in WebHybrid directory 46
  • 48. 48