SlideShare uma empresa Scribd logo
1 de 44
Baixar para ler offline
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

Mais conteúdo relacionado

Mais procurados

OpenGL Introduction.
OpenGL Introduction.OpenGL Introduction.
OpenGL Introduction.
Girish Ghate
 

Mais procurados (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
 

Destaque

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
 
Apostila pablo stolze
Apostila pablo stolzeApostila pablo stolze
Apostila pablo stolze
ILDA VALENTIM
 

Destaque (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
 

Semelhante a Building the QML Run-time

Deltacloud Presentation - OSSConf 2010
Deltacloud Presentation - OSSConf 2010Deltacloud Presentation - OSSConf 2010
Deltacloud Presentation - OSSConf 2010
Michal Fojtik
 
Untitled presentation(4)
Untitled presentation(4)Untitled presentation(4)
Untitled presentation(4)
chan20kaur
 

Semelhante a 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
 

Mais de Johan Thelin

Mais 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
 

Último

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
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
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 

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