SlideShare une entreprise Scribd logo
1  sur  44
Télécharger pour lire hors ligne
Building the run-time
     by Johan Thelin
       Pelagicore




       Copyright©2012 Johan Thelin
                CC-BY-SA
Bio
●   Johan Thelin                                    @e8johan

●   Worked with Qt
    since 10+ years
●   Author
    ●   FoQD
    ●   Articles
    ●   Tutorials
●   Embedded Linux
                      Copyright©2012 Johan Thelin
                               CC-BY-SA
Work



●   Produces an In-Vehicle Infotainment (IVI) framework
●   Open Source / Linux / Qt
●   GENIVI / LinuxFoundation / Ubuntu Core


●   We're hiring!
    ●   http://www.pelagicore.com/career.html
                           Copyright©2012 Johan Thelin
                                    CC-BY-SA
Demo Screens




  Copyright©2012 Johan Thelin
           CC-BY-SA
Copyright©2012 Johan Thelin
         CC-BY-SA
Copyright©2012 Johan Thelin
         CC-BY-SA
Copyright©2012 Johan Thelin
         CC-BY-SA
Copyright©2012 Johan Thelin
         CC-BY-SA
QML is Productive
●   Developed over 2.5 months for CES 2012
    ●   Interaction and graphics design
    ●   Run-time and QML development
    ●   ~5 full time persons involved (team of 15)


●   The code consists of
    ●   5986 loc (4871 / 1115 according to cloc)
    ●   10312 lines of QML (not loc)

                        Copyright©2012 Johan Thelin
                                 CC-BY-SA
QML in Five Slides




    Copyright©2012 Johan Thelin
             CC-BY-SA
QML 1(5) – Creating and Naming
import QtQuick 1.0
Rectangle {
     id: root
     Rectangle {
         id: red
     }
     Rectangle {
         id: yellow
     }
}
                      Copyright©2012 Johan Thelin
                               CC-BY-SA
QML 2(5) – Basic Items
                                           Rectangle {
                                             width: …
●   Rectangle                                height: …
                                             color: “#abcdef”
                                           }


                                           Image {
●   Image                                  }
                                             source: “...”



                                           Text {
                                             text: “abc 123”
●   Text         abc 123                     font.family: “helvetica”
                                             font.pixelSize: 25
                                             color: “black”
                                           }

●   MouseArea
                      Copyright©2012 Johan Thelin
                               CC-BY-SA
QML 3(5) – Binding and Actions
Rectangle {
    id: red
    width: 100; height: yellow.height
    color: “red”
    MouseArea {
        anchors.fill: parent
        onClicked: console.log(“I'm clicked!”)
    }
}

                   Copyright©2012 Johan Thelin
                            CC-BY-SA
QML 4(5) - Components
// Button.qml
Rectangle {
    id: root
    signal clicked
    property string text
    Text { anchors.centerIn: parent; text: root.text }
    MouseArea {
        anchors.fill: parent
        onClicked: root.clicked()
    }
}


// main.qml
Button { text: “Click me!”; onClicked: { … } }

                           Copyright©2012 Johan Thelin
                                    CC-BY-SA
QML 5(5) – States and Transitions
Rectangle {
    id: r
    states: [
        State { name: “either”
              PropertyChanges { target: r; opacity: 1.0 } },
        State { name: “or”
              PropertyChanges { target: r; opacity: 0.2 } }
    ]
    state: “either”
    transitions: [
        Transition {
              PropertyAnimation { properties: “opacity”; duration: 3000 }
        }
    ]
}

                              Copyright©2012 Johan Thelin
                                       CC-BY-SA
QML, Declarative and QtQuick
●   QtQuick consists of
    ●   QML – the Qt Meta Language
    ●   QtDeclarative – the Qt module for executing QML
    ●   Tooling – Visual
        designer, profiler,
        viewer, etc




                          Copyright©2012 Johan Thelin
                                   CC-BY-SA
The Demonstrator




    Copyright©2012 Johan Thelin
             CC-BY-SA
Taking one Step Back


       User Experience




            Run-time




          Environment




      Copyright©2012 Johan Thelin
               CC-BY-SA
Taking one Step Back


    QML                             HTML5




              Qt and C++




                   Linux




          Copyright©2012 Johan Thelin
                   CC-BY-SA
Taking one Step Back


                      WebKit                WebKit2
QML
                      Qt 4.x                 Qt 5.x



         Deep
      Integration                             WebChannels




                    Qt and C++




              Copyright©2012 Johan Thelin
                       CC-BY-SA
The Interface


                     QML




 Values
                                          Classes
Objects




                Qt and C++




            Copyright©2012 Johan Thelin
                     CC-BY-SA
A Basic Run-Time
int main(int argc, char **argv)
{
    QApplication a(argc, argv);
    QDeclarativeView view;
    view.setSource(“main.qml”);
    view.show();
    return a.exec();
}
               Copyright©2012 Johan Thelin
                        CC-BY-SA
Exposing a Value
●   Expose it as a root context property, i.e. a
    global variable
      view.rootContext()->
        setContextProperty(“itemWidth”, 350);


●   Bind to it in QML
      Rectangle {
          width: itemWidth
      }
                        Copyright©2012 Johan Thelin
                                 CC-BY-SA
Exposing an Object
class ClimateControl : public QObject {
     Q_OBJECT
     Q_PROPERTY(int fanSpeed READ fanSpeed
          WRITE setFanSpeed NOTIFY fanSpeedChanged)


public:
     Q_INVOKABLE resetClimate();


     int fanSpeed() const;
     void setFanSpeed(int);
                                          Image {
signals:                                    source: “fan-image-” +
     void climateReset();                     climate.fanSpeed + “.png”
     void fanSpeedChanged();              }
};

                               Copyright©2012 Johan Thelin
                                        CC-BY-SA
Exposing an Item
●   Inherit QDeclarativeItem
    ●   Position and size
    ●   Anchoring
    ●   Keyboard focus


●   For Qt 5, inherit QQuickPaintedItem
    ●   Slightly different signature, but nothing dramatical
    ●   http://bit.ly/y17W1n (Zchydem)


●   Register using qmlRegisterType
        qmlRegisterType<MapItem>(“com.pelagicore.navigation”,
             1, 0, “Map”);

                                  Copyright©2012 Johan Thelin
                                           CC-BY-SA
From QML
import com.pelagicore.navigation 1.0


Map {
    pitch: 30
    zoom: 128
    position: vehicle.position
}

                 Copyright©2012 Johan Thelin
                          CC-BY-SA
Exposing a Class
●   An item is just another QObject – you can
    expose more!
    ●   Functional building blocks
    ●   Dynamic control elements
    ●   etc


●   Just qmlRegisterType any type derived from
    QObject and let QML handle the instantiation


                         Copyright©2012 Johan Thelin
                                  CC-BY-SA
Models
●   The QAbstractItemModel interface provides a
    standardized way to expose data models in Qt
    ●   Can be exposed both as objects and classes


●   An ideal way to expose lists of data to QML
    ●   The current playlist
    ●   The locations of restaurants in the vicinity
    ●   A list of tweets


                           Copyright©2012 Johan Thelin
                                    CC-BY-SA
A Basic Model
class PlayListModel : public QAbstractListModel {
     Q_OBJECT
public:
     int rowCount() const;
     QVariant data(const QModelIndex&, int) const;
     QVariant headerData(int,
          Qt::Orientation, int) const;
};



                     Copyright©2012 Johan Thelin
                              CC-BY-SA
Models in QML



 Model




                                                 View




                                       Separates the presentation
Delegate                                 from the visualization!

              Copyright©2012 Johan Thelin
                       CC-BY-SA
Available Views

GridView




               PathView
                                            ListView




              Copyright©2012 Johan Thelin
                       CC-BY-SA
And from QML...
●   Exposed as an object
      ListView {
          model: media.playlist
          delegate: PlayListDelegate {}
      }


●   Exposed as a class
      MediaSearchModel { id: mediaModel }
      ListView {
          model: mediaModel
          delegate: MediaDelegate {}
      }

                           Copyright©2012 Johan Thelin
                                    CC-BY-SA
Exposing Different Roles
●   For each element of a model, there can be
    multiple roles
●   Using QAbstractItemModel::setRoleNames
    more roles can be named
●   Allows for easy-to-read delegates
     Text { text: albumName }
     Text { text: songDuration }
     Image { source: albumArtUrl }


                     Copyright©2012 Johan Thelin
                              CC-BY-SA
Asynchronous Data Retrieval
●   Use canFetchMore and fetchMore to request more data
     bool canFetchMore(const QModelIndex&);
     void fetchMore(const QModelIndex&);


●   Use beginInsertRows and endInsertRows when the data
    has been retrieved
     void MyModel::gotMoreData() {
          beginInsertRows(parent, first, last);
          updateModelWithNewData();
          endInserRows();
     }

                        Copyright©2012 Johan Thelin
                                 CC-BY-SA
Prototyping Models in QML
ListModel {
    id: musicModel


    ListElement {
         albumName: “The Wall”
         songTitle: “Empty Spaces”
    }
    ListElement {
         …
}
                     Copyright©2012 Johan Thelin
                              CC-BY-SA
When to do what?




   Copyright©2012 Johan Thelin
            CC-BY-SA
The Goals
●   QML controls
    ●   Appearance
    ●   Behaviour
●   The run-time provides
    ●   Functionality                                  CC-BY ekkebus
                                                       http://www.flickr.com/photos/ekkebus/5020840511/
    ●   Access to state and data
●   A well defined interface allows designers and
    run-time developers to work in parallel

                         Copyright©2012 Johan Thelin
                                  CC-BY-SA
The State of the System
●   Use system-wide singletons per function, e.g.
    ●   vehicle, climate, media


●   Rationale
    ●   There is only a single vehicle, so only one state
    ●   Dividing them among functional areas
        –   gives small, clean interfaces
        –   allows limited system access for sandboxed elements


                             Copyright©2012 Johan Thelin
                                      CC-BY-SA
The State of the System
●   Provide properties
    ●   media.masterVolume
●   Provide signals for events
    ●   navigation.onDestinationReached
●   Provide methods for common functions
    ●   media.mute




                       Copyright©2012 Johan Thelin
                                CC-BY-SA
The State from QML
VolumeIndicator { volume: media.masterVolume }


Slider { onValueChanged: {
        media.masterVolume = value;
    }
}


MuteButton { onClicked: media.mute(); }


Connections {
    target: navigation
    onDestinationReached: navigation.resetDestination();
}

                         Copyright©2012 Johan Thelin
                                  CC-BY-SA
Data From the System
●   Use models for all data that is not a state
●   What is a state and what is a model?
    ●   Climate zone states?
        –   driverTemperature, passengerTemperature, rearTemperature
    ●   Climate zone as a model?
                  zoneName                    temperature
                  Driver                      20.5
                  Passenger                   20.0
                  Rear                        22.0

    ●   How dynamic is your system?
    ●   How dynamic is your design?
                               Copyright©2012 Johan Thelin
                                        CC-BY-SA
Object or Class
●   Exposing a model as an object
    ●   There is only one playlist, use media.playlist, e.g.
           ListView { model: media.playlist }

●   Exposing a model as a class
    ●   There can be any number of search results, use MediaSearchModel, e.g.
           MediaSearchModel {
                  id: search
                  filter: “artist=Pink Floyd”
           }
           PathView {
                  model: search
           }

                                        Copyright©2012 Johan Thelin
                                                 CC-BY-SA
The Engineering Choice
●   QML forces you to separate form and function
●   It also gives you new choices
    ●   Limiting the run-time environment saves
        development time short term
    ●   Generalizing the run-time improves reuseability


●   How do you work?
●   What are you building?

                        Copyright©2012 Johan Thelin
                                 CC-BY-SA
Thank you!
           @e8johan
johan.thelin@pelagicore.com




        Copyright©2012 Johan Thelin
                 CC-BY-SA

Contenu connexe

Tendances

Qt for beginners part 1 overview and key concepts
Qt for beginners part 1   overview and key conceptsQt for beginners part 1   overview and key concepts
Qt for beginners part 1 overview and key conceptsICS
 
Qt Internationalization
Qt InternationalizationQt Internationalization
Qt InternationalizationICS
 
Qt for beginners part 2 widgets
Qt for beginners part 2   widgetsQt for beginners part 2   widgets
Qt for beginners part 2 widgetsICS
 
Convert Your Legacy OpenGL Code to Modern OpenGL with Qt
Convert Your Legacy OpenGL Code to Modern OpenGL with QtConvert Your Legacy OpenGL Code to Modern OpenGL with Qt
Convert Your Legacy OpenGL Code to Modern OpenGL with QtICS
 
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 3
Best Practices in Qt Quick/QML - Part 3Best Practices in Qt Quick/QML - Part 3
Best Practices in Qt Quick/QML - Part 3ICS
 
Qt and QML performance tips & tricks for Qt 4.7
Qt and QML performance tips & tricks for Qt 4.7Qt and QML performance tips & tricks for Qt 4.7
Qt and QML performance tips & tricks for Qt 4.7Pasi Kellokoski
 
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
 
Qt for beginners part 5 ask the experts
Qt for beginners part 5   ask the expertsQt for beginners part 5   ask the experts
Qt for beginners part 5 ask the expertsICS
 
A Brief Introduction to the Qt Application Framework
A Brief Introduction to the Qt Application FrameworkA Brief Introduction to the Qt Application Framework
A Brief Introduction to the Qt Application FrameworkZachary Blair
 
So I Downloaded Qt, Now What?
So I Downloaded Qt, Now What?So I Downloaded Qt, Now What?
So I Downloaded Qt, Now What?Janel Heilbrunn
 
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
 
Migrating from Photon to Qt
Migrating from Photon to QtMigrating from Photon to Qt
Migrating from Photon to QtJanel Heilbrunn
 
OpenGL Introduction.
OpenGL Introduction.OpenGL Introduction.
OpenGL Introduction.Girish Ghate
 

Tendances (20)

Qt for beginners part 1 overview and key concepts
Qt for beginners part 1   overview and key conceptsQt for beginners part 1   overview and key concepts
Qt for beginners part 1 overview and key concepts
 
Qt Internationalization
Qt InternationalizationQt Internationalization
Qt Internationalization
 
Qt for beginners part 2 widgets
Qt for beginners part 2   widgetsQt for beginners part 2   widgets
Qt for beginners part 2 widgets
 
Convert Your Legacy OpenGL Code to Modern OpenGL with Qt
Convert Your Legacy OpenGL Code to Modern OpenGL with QtConvert Your Legacy OpenGL Code to Modern OpenGL with Qt
Convert Your Legacy OpenGL Code to Modern OpenGL with Qt
 
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 3
Best Practices in Qt Quick/QML - Part 3Best Practices in Qt Quick/QML - Part 3
Best Practices in Qt Quick/QML - Part 3
 
Qt and QML performance tips & tricks for Qt 4.7
Qt and QML performance tips & tricks for Qt 4.7Qt and QML performance tips & tricks for Qt 4.7
Qt and QML performance tips & tricks for Qt 4.7
 
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
 
Qt for beginners part 5 ask the experts
Qt for beginners part 5   ask the expertsQt for beginners part 5   ask the experts
Qt for beginners part 5 ask the experts
 
Treinamento Qt básico - aula I
Treinamento Qt básico - aula ITreinamento Qt básico - aula I
Treinamento Qt básico - aula I
 
A Brief Introduction to the Qt Application Framework
A Brief Introduction to the Qt Application FrameworkA Brief Introduction to the Qt Application Framework
A Brief Introduction to the Qt Application Framework
 
Qt Widget In-Depth
Qt Widget In-DepthQt Widget In-Depth
Qt Widget In-Depth
 
So I Downloaded Qt, Now What?
So I Downloaded Qt, Now What?So I Downloaded Qt, Now What?
So I Downloaded Qt, Now What?
 
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 5 - C++ and Widgets
Qt 5 - C++ and WidgetsQt 5 - C++ and Widgets
Qt 5 - C++ and Widgets
 
Migrating from Photon to Qt
Migrating from Photon to QtMigrating from Photon to Qt
Migrating from Photon to Qt
 
Treinamento Qt básico - aula II
Treinamento Qt básico - aula IITreinamento Qt básico - aula II
Treinamento Qt básico - aula II
 
OpenGL Introduction.
OpenGL Introduction.OpenGL Introduction.
OpenGL Introduction.
 
The Future of Qt Widgets
The Future of Qt WidgetsThe Future of Qt Widgets
The Future of Qt Widgets
 
Programming with OpenGL
Programming with OpenGLProgramming with OpenGL
Programming with OpenGL
 

En vedette

Repair My Credit Score
Repair My Credit ScoreRepair My Credit Score
Repair My Credit ScoreLegacy Legal
 
E-Tech 7.2 Summer 2010
E-Tech 7.2 Summer 2010E-Tech 7.2 Summer 2010
E-Tech 7.2 Summer 2010Candiek
 
Best Practices in Qt Quick/QML - Part IV
Best Practices in Qt Quick/QML - Part IVBest Practices in Qt Quick/QML - Part IV
Best Practices in Qt Quick/QML - Part IVICS
 
Informativo n° 25 2º básico a- viernes 06 de septiembre (2)
Informativo n° 25  2º básico a- viernes 06 de septiembre (2)Informativo n° 25  2º básico a- viernes 06 de septiembre (2)
Informativo n° 25 2º básico a- viernes 06 de septiembre (2)Colegio Camilo Henríquez
 
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
 
Apostila pablo stolze
Apostila pablo stolzeApostila pablo stolze
Apostila pablo stolzeILDA VALENTIM
 
English Study and History of the English Lanaguage
English Study and History of the English LanaguageEnglish Study and History of the English Lanaguage
English Study and History of the English LanaguageISE NUESTRA SEÑORA DE CHOTA
 
Trabajo Nº 4 - Proyecto Pueblos Originarios de Chile
Trabajo Nº 4 - Proyecto Pueblos Originarios de ChileTrabajo Nº 4 - Proyecto Pueblos Originarios de Chile
Trabajo Nº 4 - Proyecto Pueblos Originarios de ChileColegio Camilo Henríquez
 

En vedette (9)

Repair My Credit Score
Repair My Credit ScoreRepair My Credit Score
Repair My Credit Score
 
E-Tech 7.2 Summer 2010
E-Tech 7.2 Summer 2010E-Tech 7.2 Summer 2010
E-Tech 7.2 Summer 2010
 
Best Practices in Qt Quick/QML - Part IV
Best Practices in Qt Quick/QML - Part IVBest Practices in Qt Quick/QML - Part IV
Best Practices in Qt Quick/QML - Part IV
 
Informativo n° 25 2º básico a- viernes 06 de septiembre (2)
Informativo n° 25  2º básico a- viernes 06 de septiembre (2)Informativo n° 25  2º básico a- viernes 06 de septiembre (2)
Informativo n° 25 2º básico a- viernes 06 de septiembre (2)
 
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
 
Apostila pablo stolze
Apostila pablo stolzeApostila pablo stolze
Apostila pablo stolze
 
English Study and History of the English Lanaguage
English Study and History of the English LanaguageEnglish Study and History of the English Lanaguage
English Study and History of the English Lanaguage
 
Trabajo Nº 4 - Proyecto Pueblos Originarios de Chile
Trabajo Nº 4 - Proyecto Pueblos Originarios de ChileTrabajo Nº 4 - Proyecto Pueblos Originarios de Chile
Trabajo Nº 4 - Proyecto Pueblos Originarios de Chile
 
UK-culture
UK-cultureUK-culture
UK-culture
 

Similaire à Building the QML Run-time

An Introductory course on Verilog HDL-Verilog hdl ppr
An Introductory course on Verilog HDL-Verilog hdl pprAn Introductory course on Verilog HDL-Verilog hdl ppr
An Introductory course on Verilog HDL-Verilog hdl pprPrabhavathi P
 
Fun with QML
Fun with QMLFun with QML
Fun with QMLICS
 
Deltacloud Presentation - OSSConf 2010
Deltacloud Presentation - OSSConf 2010Deltacloud Presentation - OSSConf 2010
Deltacloud Presentation - OSSConf 2010Michal Fojtik
 
Model serving made easy using Kedro pipelines - Mariusz Strzelecki, GetInData
Model serving made easy using Kedro pipelines - Mariusz Strzelecki, GetInDataModel serving made easy using Kedro pipelines - Mariusz Strzelecki, GetInData
Model serving made easy using Kedro pipelines - Mariusz Strzelecki, GetInDataGetInData
 
Qt quick at Cybercom Developer Day 2010 by Alexis Menard 7.9.2010
Qt quick at Cybercom Developer Day 2010 by Alexis Menard 7.9.2010Qt quick at Cybercom Developer Day 2010 by Alexis Menard 7.9.2010
Qt quick at Cybercom Developer Day 2010 by Alexis Menard 7.9.2010CybercomChannel
 
C++ Webinar "Why Should You Learn C++ in 2021-22?"
C++ Webinar "Why Should You Learn C++ in 2021-22?"C++ Webinar "Why Should You Learn C++ in 2021-22?"
C++ Webinar "Why Should You Learn C++ in 2021-22?"GlobalLogic Ukraine
 
Porting Motif Applications to Qt - Webinar
Porting Motif Applications to Qt - WebinarPorting Motif Applications to Qt - Webinar
Porting Motif Applications to Qt - WebinarICS
 
Porting Motif Applications to Qt - Webinar
Porting Motif Applications to Qt - WebinarPorting Motif Applications to Qt - Webinar
Porting Motif Applications to Qt - WebinarJanel Heilbrunn
 
Feb 2018 Spinnaker Meetup Reddit Presentation
Feb 2018 Spinnaker Meetup Reddit PresentationFeb 2018 Spinnaker Meetup Reddit Presentation
Feb 2018 Spinnaker Meetup Reddit PresentationEdward Ceaser
 
Universal Declarative Services - Simon Chemouil
Universal Declarative Services - Simon ChemouilUniversal Declarative Services - Simon Chemouil
Universal Declarative Services - Simon Chemouilmfrancis
 
Andreas Jakl Software Development on Nokia Deviceswith Qt
Andreas Jakl Software Development on Nokia Deviceswith QtAndreas Jakl Software Development on Nokia Deviceswith Qt
Andreas Jakl Software Development on Nokia Deviceswith QtNokiaAppForum
 
Luca Filigheddu - Sviluppiamo in Cascades per Blackberry 10
Luca Filigheddu - Sviluppiamo in Cascades per Blackberry 10Luca Filigheddu - Sviluppiamo in Cascades per Blackberry 10
Luca Filigheddu - Sviluppiamo in Cascades per Blackberry 10Girl Geek Dinners Milano
 
Untitled presentation(4)
Untitled presentation(4)Untitled presentation(4)
Untitled presentation(4)chan20kaur
 
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
 
Java and Serverless - A Match Made In Heaven, Part 2
Java and Serverless - A Match Made In Heaven, Part 2Java and Serverless - A Match Made In Heaven, Part 2
Java and Serverless - A Match Made In Heaven, Part 2Curity
 

Similaire à Building the QML Run-time (20)

An Introductory course on Verilog HDL-Verilog hdl ppr
An Introductory course on Verilog HDL-Verilog hdl pprAn Introductory course on Verilog HDL-Verilog hdl ppr
An Introductory course on Verilog HDL-Verilog hdl ppr
 
Fun with QML
Fun with QMLFun with QML
Fun with QML
 
Deltacloud Presentation - OSSConf 2010
Deltacloud Presentation - OSSConf 2010Deltacloud Presentation - OSSConf 2010
Deltacloud Presentation - OSSConf 2010
 
Model serving made easy using Kedro pipelines - Mariusz Strzelecki, GetInData
Model serving made easy using Kedro pipelines - Mariusz Strzelecki, GetInDataModel serving made easy using Kedro pipelines - Mariusz Strzelecki, GetInData
Model serving made easy using Kedro pipelines - Mariusz Strzelecki, GetInData
 
Qt quick at Cybercom Developer Day 2010 by Alexis Menard 7.9.2010
Qt quick at Cybercom Developer Day 2010 by Alexis Menard 7.9.2010Qt quick at Cybercom Developer Day 2010 by Alexis Menard 7.9.2010
Qt quick at Cybercom Developer Day 2010 by Alexis Menard 7.9.2010
 
C++ Webinar "Why Should You Learn C++ in 2021-22?"
C++ Webinar "Why Should You Learn C++ in 2021-22?"C++ Webinar "Why Should You Learn C++ in 2021-22?"
C++ Webinar "Why Should You Learn C++ in 2021-22?"
 
Introduction to 2D/3D Graphics
Introduction to 2D/3D GraphicsIntroduction to 2D/3D Graphics
Introduction to 2D/3D Graphics
 
Google Cloud Dataflow
Google Cloud DataflowGoogle Cloud Dataflow
Google Cloud Dataflow
 
Porting Motif Applications to Qt - Webinar
Porting Motif Applications to Qt - WebinarPorting Motif Applications to Qt - Webinar
Porting Motif Applications to Qt - Webinar
 
Porting Motif Applications to Qt - Webinar
Porting Motif Applications to Qt - WebinarPorting Motif Applications to Qt - Webinar
Porting Motif Applications to Qt - Webinar
 
Feb 2018 Spinnaker Meetup Reddit Presentation
Feb 2018 Spinnaker Meetup Reddit PresentationFeb 2018 Spinnaker Meetup Reddit Presentation
Feb 2018 Spinnaker Meetup Reddit Presentation
 
Universal Declarative Services - Simon Chemouil
Universal Declarative Services - Simon ChemouilUniversal Declarative Services - Simon Chemouil
Universal Declarative Services - Simon Chemouil
 
Andreas Jakl Software Development on Nokia Deviceswith Qt
Andreas Jakl Software Development on Nokia Deviceswith QtAndreas Jakl Software Development on Nokia Deviceswith Qt
Andreas Jakl Software Development on Nokia Deviceswith Qt
 
HTML literals, the JSX of the platform
HTML literals, the JSX of the platformHTML literals, the JSX of the platform
HTML literals, the JSX of the platform
 
Luca Filigheddu - Sviluppiamo in Cascades per Blackberry 10
Luca Filigheddu - Sviluppiamo in Cascades per Blackberry 10Luca Filigheddu - Sviluppiamo in Cascades per Blackberry 10
Luca Filigheddu - Sviluppiamo in Cascades per Blackberry 10
 
Untitled presentation(4)
Untitled presentation(4)Untitled presentation(4)
Untitled presentation(4)
 
Qt coin3d soqt
Qt coin3d soqtQt coin3d soqt
Qt coin3d soqt
 
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
QtQt
Qt
 
Java and Serverless - A Match Made In Heaven, Part 2
Java and Serverless - A Match Made In Heaven, Part 2Java and Serverless - A Match Made In Heaven, Part 2
Java and Serverless - A Match Made In Heaven, Part 2
 

Plus de Johan Thelin

Degrees of Freedom
Degrees of FreedomDegrees of Freedom
Degrees of FreedomJohan Thelin
 
Hacktoberfest - An Open Source Story
Hacktoberfest - An Open Source StoryHacktoberfest - An Open Source Story
Hacktoberfest - An Open Source StoryJohan Thelin
 
Open Source on Wheels - Tech Day by Init 2017
Open Source on Wheels - Tech Day by Init 2017Open Source on Wheels - Tech Day by Init 2017
Open Source on Wheels - Tech Day by Init 2017Johan Thelin
 
Qt Automotive Suite - under the hood // Qt World Summit 2017
Qt Automotive Suite - under the hood // Qt World Summit 2017Qt Automotive Suite - under the hood // Qt World Summit 2017
Qt Automotive Suite - under the hood // Qt World Summit 2017Johan Thelin
 
QtWS15 Revolutionizing Automotive with Qt
QtWS15 Revolutionizing Automotive with QtQtWS15 Revolutionizing Automotive with Qt
QtWS15 Revolutionizing Automotive with QtJohan Thelin
 
Introduction to Qt Embedded
Introduction to Qt EmbeddedIntroduction to Qt Embedded
Introduction to Qt EmbeddedJohan Thelin
 

Plus de Johan Thelin (6)

Degrees of Freedom
Degrees of FreedomDegrees of Freedom
Degrees of Freedom
 
Hacktoberfest - An Open Source Story
Hacktoberfest - An Open Source StoryHacktoberfest - An Open Source Story
Hacktoberfest - An Open Source Story
 
Open Source on Wheels - Tech Day by Init 2017
Open Source on Wheels - Tech Day by Init 2017Open Source on Wheels - Tech Day by Init 2017
Open Source on Wheels - Tech Day by Init 2017
 
Qt Automotive Suite - under the hood // Qt World Summit 2017
Qt Automotive Suite - under the hood // Qt World Summit 2017Qt Automotive Suite - under the hood // Qt World Summit 2017
Qt Automotive Suite - under the hood // Qt World Summit 2017
 
QtWS15 Revolutionizing Automotive with Qt
QtWS15 Revolutionizing Automotive with QtQtWS15 Revolutionizing Automotive with Qt
QtWS15 Revolutionizing Automotive with Qt
 
Introduction to Qt Embedded
Introduction to Qt EmbeddedIntroduction to Qt Embedded
Introduction to Qt Embedded
 

Dernier

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 

Dernier (20)

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 

Building the QML Run-time

  • 1. Building the run-time by Johan Thelin Pelagicore Copyright©2012 Johan Thelin CC-BY-SA
  • 2. Bio ● Johan Thelin @e8johan ● Worked with Qt since 10+ years ● Author ● FoQD ● Articles ● Tutorials ● Embedded Linux Copyright©2012 Johan Thelin CC-BY-SA
  • 3. Work ● Produces an In-Vehicle Infotainment (IVI) framework ● Open Source / Linux / Qt ● GENIVI / LinuxFoundation / Ubuntu Core ● We're hiring! ● http://www.pelagicore.com/career.html Copyright©2012 Johan Thelin CC-BY-SA
  • 4. Demo Screens Copyright©2012 Johan Thelin CC-BY-SA
  • 9. QML is Productive ● Developed over 2.5 months for CES 2012 ● Interaction and graphics design ● Run-time and QML development ● ~5 full time persons involved (team of 15) ● The code consists of ● 5986 loc (4871 / 1115 according to cloc) ● 10312 lines of QML (not loc) Copyright©2012 Johan Thelin CC-BY-SA
  • 10. QML in Five Slides Copyright©2012 Johan Thelin CC-BY-SA
  • 11. QML 1(5) – Creating and Naming import QtQuick 1.0 Rectangle { id: root Rectangle { id: red } Rectangle { id: yellow } } Copyright©2012 Johan Thelin CC-BY-SA
  • 12. QML 2(5) – Basic Items Rectangle { width: … ● Rectangle height: … color: “#abcdef” } Image { ● Image } source: “...” Text { text: “abc 123” ● Text abc 123 font.family: “helvetica” font.pixelSize: 25 color: “black” } ● MouseArea Copyright©2012 Johan Thelin CC-BY-SA
  • 13. QML 3(5) – Binding and Actions Rectangle { id: red width: 100; height: yellow.height color: “red” MouseArea { anchors.fill: parent onClicked: console.log(“I'm clicked!”) } } Copyright©2012 Johan Thelin CC-BY-SA
  • 14. QML 4(5) - Components // Button.qml Rectangle { id: root signal clicked property string text Text { anchors.centerIn: parent; text: root.text } MouseArea { anchors.fill: parent onClicked: root.clicked() } } // main.qml Button { text: “Click me!”; onClicked: { … } } Copyright©2012 Johan Thelin CC-BY-SA
  • 15. QML 5(5) – States and Transitions Rectangle { id: r states: [ State { name: “either” PropertyChanges { target: r; opacity: 1.0 } }, State { name: “or” PropertyChanges { target: r; opacity: 0.2 } } ] state: “either” transitions: [ Transition { PropertyAnimation { properties: “opacity”; duration: 3000 } } ] } Copyright©2012 Johan Thelin CC-BY-SA
  • 16. QML, Declarative and QtQuick ● QtQuick consists of ● QML – the Qt Meta Language ● QtDeclarative – the Qt module for executing QML ● Tooling – Visual designer, profiler, viewer, etc Copyright©2012 Johan Thelin CC-BY-SA
  • 17. The Demonstrator Copyright©2012 Johan Thelin CC-BY-SA
  • 18. Taking one Step Back User Experience Run-time Environment Copyright©2012 Johan Thelin CC-BY-SA
  • 19. Taking one Step Back QML HTML5 Qt and C++ Linux Copyright©2012 Johan Thelin CC-BY-SA
  • 20. Taking one Step Back WebKit WebKit2 QML Qt 4.x Qt 5.x Deep Integration WebChannels Qt and C++ Copyright©2012 Johan Thelin CC-BY-SA
  • 21. The Interface QML Values Classes Objects Qt and C++ Copyright©2012 Johan Thelin CC-BY-SA
  • 22. A Basic Run-Time int main(int argc, char **argv) { QApplication a(argc, argv); QDeclarativeView view; view.setSource(“main.qml”); view.show(); return a.exec(); } Copyright©2012 Johan Thelin CC-BY-SA
  • 23. Exposing a Value ● Expose it as a root context property, i.e. a global variable view.rootContext()-> setContextProperty(“itemWidth”, 350); ● Bind to it in QML Rectangle { width: itemWidth } Copyright©2012 Johan Thelin CC-BY-SA
  • 24. Exposing an Object class ClimateControl : public QObject { Q_OBJECT Q_PROPERTY(int fanSpeed READ fanSpeed WRITE setFanSpeed NOTIFY fanSpeedChanged) public: Q_INVOKABLE resetClimate(); int fanSpeed() const; void setFanSpeed(int); Image { signals: source: “fan-image-” + void climateReset(); climate.fanSpeed + “.png” void fanSpeedChanged(); } }; Copyright©2012 Johan Thelin CC-BY-SA
  • 25. Exposing an Item ● Inherit QDeclarativeItem ● Position and size ● Anchoring ● Keyboard focus ● For Qt 5, inherit QQuickPaintedItem ● Slightly different signature, but nothing dramatical ● http://bit.ly/y17W1n (Zchydem) ● Register using qmlRegisterType qmlRegisterType<MapItem>(“com.pelagicore.navigation”, 1, 0, “Map”); Copyright©2012 Johan Thelin CC-BY-SA
  • 26. From QML import com.pelagicore.navigation 1.0 Map { pitch: 30 zoom: 128 position: vehicle.position } Copyright©2012 Johan Thelin CC-BY-SA
  • 27. Exposing a Class ● An item is just another QObject – you can expose more! ● Functional building blocks ● Dynamic control elements ● etc ● Just qmlRegisterType any type derived from QObject and let QML handle the instantiation Copyright©2012 Johan Thelin CC-BY-SA
  • 28. Models ● The QAbstractItemModel interface provides a standardized way to expose data models in Qt ● Can be exposed both as objects and classes ● An ideal way to expose lists of data to QML ● The current playlist ● The locations of restaurants in the vicinity ● A list of tweets Copyright©2012 Johan Thelin CC-BY-SA
  • 29. A Basic Model class PlayListModel : public QAbstractListModel { Q_OBJECT public: int rowCount() const; QVariant data(const QModelIndex&, int) const; QVariant headerData(int, Qt::Orientation, int) const; }; Copyright©2012 Johan Thelin CC-BY-SA
  • 30. Models in QML Model View Separates the presentation Delegate from the visualization! Copyright©2012 Johan Thelin CC-BY-SA
  • 31. Available Views GridView PathView ListView Copyright©2012 Johan Thelin CC-BY-SA
  • 32. And from QML... ● Exposed as an object ListView { model: media.playlist delegate: PlayListDelegate {} } ● Exposed as a class MediaSearchModel { id: mediaModel } ListView { model: mediaModel delegate: MediaDelegate {} } Copyright©2012 Johan Thelin CC-BY-SA
  • 33. Exposing Different Roles ● For each element of a model, there can be multiple roles ● Using QAbstractItemModel::setRoleNames more roles can be named ● Allows for easy-to-read delegates Text { text: albumName } Text { text: songDuration } Image { source: albumArtUrl } Copyright©2012 Johan Thelin CC-BY-SA
  • 34. Asynchronous Data Retrieval ● Use canFetchMore and fetchMore to request more data bool canFetchMore(const QModelIndex&); void fetchMore(const QModelIndex&); ● Use beginInsertRows and endInsertRows when the data has been retrieved void MyModel::gotMoreData() { beginInsertRows(parent, first, last); updateModelWithNewData(); endInserRows(); } Copyright©2012 Johan Thelin CC-BY-SA
  • 35. Prototyping Models in QML ListModel { id: musicModel ListElement { albumName: “The Wall” songTitle: “Empty Spaces” } ListElement { … } Copyright©2012 Johan Thelin CC-BY-SA
  • 36. When to do what? Copyright©2012 Johan Thelin CC-BY-SA
  • 37. The Goals ● QML controls ● Appearance ● Behaviour ● The run-time provides ● Functionality CC-BY ekkebus http://www.flickr.com/photos/ekkebus/5020840511/ ● Access to state and data ● A well defined interface allows designers and run-time developers to work in parallel Copyright©2012 Johan Thelin CC-BY-SA
  • 38. The State of the System ● Use system-wide singletons per function, e.g. ● vehicle, climate, media ● Rationale ● There is only a single vehicle, so only one state ● Dividing them among functional areas – gives small, clean interfaces – allows limited system access for sandboxed elements Copyright©2012 Johan Thelin CC-BY-SA
  • 39. The State of the System ● Provide properties ● media.masterVolume ● Provide signals for events ● navigation.onDestinationReached ● Provide methods for common functions ● media.mute Copyright©2012 Johan Thelin CC-BY-SA
  • 40. The State from QML VolumeIndicator { volume: media.masterVolume } Slider { onValueChanged: { media.masterVolume = value; } } MuteButton { onClicked: media.mute(); } Connections { target: navigation onDestinationReached: navigation.resetDestination(); } Copyright©2012 Johan Thelin CC-BY-SA
  • 41. Data From the System ● Use models for all data that is not a state ● What is a state and what is a model? ● Climate zone states? – driverTemperature, passengerTemperature, rearTemperature ● Climate zone as a model? zoneName temperature Driver 20.5 Passenger 20.0 Rear 22.0 ● How dynamic is your system? ● How dynamic is your design? Copyright©2012 Johan Thelin CC-BY-SA
  • 42. Object or Class ● Exposing a model as an object ● There is only one playlist, use media.playlist, e.g. ListView { model: media.playlist } ● Exposing a model as a class ● There can be any number of search results, use MediaSearchModel, e.g. MediaSearchModel { id: search filter: “artist=Pink Floyd” } PathView { model: search } Copyright©2012 Johan Thelin CC-BY-SA
  • 43. The Engineering Choice ● QML forces you to separate form and function ● It also gives you new choices ● Limiting the run-time environment saves development time short term ● Generalizing the run-time improves reuseability ● How do you work? ● What are you building? Copyright©2012 Johan Thelin CC-BY-SA
  • 44. Thank you! @e8johan johan.thelin@pelagicore.com Copyright©2012 Johan Thelin CC-BY-SA