SlideShare a Scribd company logo
Qt Quick Best Practices
Part 2
Langston Ball
ICS Consulting Engineer
ICS, Inc.
Agenda
• Creating New Item
• State and Transitions
• Dynamic Creation of Items
Creating New Items
Extending Items
• Any instance of a QML item is effectively a
subclass
• Add member properties
• Add member functions
• Add signals
• There is no reason to add signals to an instance
Extending Items
Rectangle{
Text {
id: label
property int count: 1
text: “Count = ” + count
function incrementCount() {
count = count+1
}
}
Timer {
running: true
onTriggered: label.incrementCount()
}
}
Property Types
• Properties can be almost any type
• Basic: int, real, string, date, time, point
• Copies are stored
• Any valid QML type: Rectangle, Text
• These are actually pointers
• The “var” type is equivalent to Qvariant
• Use explicit types as much as you can
• They are faster
Property Types
Rectangle{
id: button
property int anInt: 1
property real aDouble: 50.5
property bool aBool: false
property string aString: “”
property var anything: 50.5
property list<point> points: [ Qt.point(0,0), Qt.point(100,100) ]
}
Dividing Code Into Components
• Often a devs to put too much code in one
QML file
• Common issue for all programming languages
• QML makes it easy to componentize your code
• Component refers to an item that can be
instanced multiple times
Creating New Items
• Simply create a new .qml file
• Type is named after the filename
• Must begin with a capital letter
• Implement
• Properties
• Signals
• Functions
Inline Button Code
Rectangle{ // Main.qml
id: toplevel
color: “black”
Rectangle {
id: button
width: 100; height: 50
color: “blue”
Text {
text: “Click Me”
}
MouseArea {
anchors.fill: parent
onPressedChanged: button.color = (pressed) ? “red” : “blue”
onClicked: toplevel.color = “white”
}
}
}
Componentized Button
Rectangle{ // Main.qml
id: toplevel
color: “black”
Button {
text: “Click Me”
onClicked: toplevel.color = “white”
}
}
Componentized Button
Rectangle{ // Button.qml
id: button
property alias text: label.text
signal clicked()
color: “blue”
width: 100; height: 50
Text {
id: label
anchors.centerIn: parent
}
MouseArea{
id: ma
anchors.fill: parent
onClicked: button.clicked()
}
}
Alias Properties
• Proxies properties to child items
• Allows hiding of implementation details
• Saves memory and binding recalculations
Property Scope
• Public Scope
• All public properties of the root item
• Custom properties defined on the root item
• Private Scope
• All child items and their properties
Public Members
Rectangle{ // Button.qml
id: button
property alias text: label.text
signal clicked()
color: “blue”
Text {
id: label
anchors.centerIn: parent
}
MouseArea{
id: ma
anchors.fill: parent
onClicked: button.clicked()
}
}
Private Members
Rectangle{ // Button.qml
id: button
property alias text: label.text
signal clicked()
color: “blue”
Text {
id: label
anchors.centerIn: parent
}
MouseArea{
id: ma
anchors.fill: parent
onClicked: button.clicked()
}
}
Private Properties
Rectangle { // Button.qml
id: button
property alias text: label.text
signal clicked()
QtObject {
id: internal
property int centerX: button.width()/2
}
Text {
x: internal.centerX
}
}
Avoid Inheriting Public Members
// Inherit from the basic Item type and hide everything else
Item { // Button.qml
id: button
property alias text: label.text
signal clicked()
Rectangle {
id: background
color: “blue”
}
Text {
id: label
anchors.centerIn: parent
}
...
}
States and Transitions
States
• State Machines can make your code “more
declarative”
• A basic state machine is built into every Item
• No parallel states or state history
States
• Every Item has a states property
• States contain
• Name
• When Clause
• List of PropertyChanges{} objects
Setting States
• Item can be set to a give state two ways
• 1) “state” property is set to the name of the
State
• item.state = “Pressed”
• 2) The when clause of the State is true
• When clauses must be mutually exclusive
• They are evaluated in creation order
Button States
Item {
Rectangle { id: bkg; color: “blue” }
MouseArea { id: ma }
states: [
State {
name: “Pressed”
when: ma.pressed
PropertyChanges { target: bkg; color: “red” }
},
State {
name: “Disabled”
when: !(ma.enabled)
PropertyChanges { target: bkg; color: “grey” }
}
]
}
Default State
• The initial bindings are the “Default State”
• The name of the default state is “”
• Default state is in effect when
• No when clauses are satisfied
• “state” property is set to “”
Properties When in a State
• The bindings of a QML document is defined
as
• The default state bindings
• Overlaid with PropertyChanges from the current
state
• This will save you a ton of typing
• States do not need to be unwound
• Set common properties in the default state
• Avoids writing duplicate PropertyChanges
Transitions
• Run animations on a state change
• Control how properties will change
• Qt will automatically interpolate values
• Control in which order properties change
Transitions
[ ... ]
transitions: [
Transition {
from: “”; to: “Pressed”
PropertyAnimation { target: bkg
properties: “color”
duration: 500
},
Transition {
from: “*”; to: “Disabled”
PropertyAnimation { target: bkg
properties: “color”
duration: 250
}
]
[ ... ]
Transition Defaults
• Transition{} defaults to
• from: “*”; to: “*”
• That Transition will apply to all state changes
• PropertyAnimation
• When a target is not specified
• That animation will apply to all items
Button Transition
Item {
Rectangle { id: bkg; color: “blue” }
MouseArea { id: ma }
states: [
State { name: “Pressed”; when: ma.pressed
PropertyChanges { target: bkg; color: “red” }
},
State { name: “Disabled”; when: !(ma.enabled)
PropertyChanges { target: bkg; color: “grey” }
}
]
transitions: [
Transition {
PropertyAnimation { properties: “color”; duration: 500 }
}
]
}
Dynamic Creation of Items
Creating Items Dynamically
• Procedural Way
• Component createObject(parent, bindings)
function
• Declarative Way
• Loader Item
• Repeater Item
• ListView / GridView Items
Procedural Creation
Item {
id: screen
property SettingDialog dialog: undefined
Button {
text: “Settings...”
onClicked: {
var component = Qt.createComponent(“SettingsDialog.qml”)
screen.dialog = component.createObject(screen,
{ anchors.centerIn: screen
})
screen.dialog.close.connect(screen.destroySettingsDialog)
}
function destroySettingsDialog()
{
screen.dialog.destroy()
screen.dialog = undefined
}
}
Procedural / Declarative Creation
Item {
id: screen
Button {
text: “Settings...”
onClicked: {
dialogComponent.createObject(screen)
}
Component {
id: dialogComponent
SettingsDialog {
anchors.centerIn: parent
onClose: destroy()
}
}
}
Declarative Creation
Item {
Button {
text: “Settings...”
onClicked: loader.sourceComponent = dialogComponent
Loader {
id: loader
anchors.fill: parent
}
Component {
id: dialogComponent
SettingsDialog {
anchors.centerIn: parent
onClose: loader.sourceComponent = undefined
}
}
}
Creating Multiple Items
Item {
width: 400; height: 400
color: “black”
Grid {
x: 5; y:5
rows: 5; columns: 5
Repeater {
model: 24
Rectangle {
width: 70; height: 70
color: “lightgreen”
}
}
}
}
Creating Multiple Items
Item {
width: 400; height: 400
color: “black”
Grid {
x: 5; y:5
rows: 5; columns: 5
Repeater {
model: 24
Rectangle {
width: 70; height: 70
color: “lightgreen”
Text {
anchors.centerIn: parent
text: index
}
}
}
}
}
Repeater
• Repeaters can use all type of data models
• ListModel
• JSON Data
• property list<type>
• QList<QObject*>
• QAbstractItemModel
• Model data is accessed via attached
properties
Thank You!
Part III: July 23rd, 2015
Http://www.ics.com/webinars
Langston Ball
ICS Consulting Engineer
ICS, Inc.
Ad

More Related Content

What's hot (20)

Qt for Beginners Part 3 - QML and Qt Quick
Qt for Beginners Part 3 - QML and Qt QuickQt for Beginners Part 3 - QML and Qt Quick
Qt for Beginners Part 3 - QML and Qt Quick
ICS
 
Best Practices in Qt Quick/QML - Part 4
Best Practices in Qt Quick/QML - Part 4Best Practices in Qt Quick/QML - Part 4
Best Practices in Qt Quick/QML - Part 4
ICS
 
Qt Design Patterns
Qt Design PatternsQt Design Patterns
Qt Design Patterns
Ynon Perek
 
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
ICS
 
[Webinar] Qt Test-Driven Development Using Google Test and Google Mock
[Webinar] Qt Test-Driven Development Using Google Test and Google Mock[Webinar] Qt Test-Driven Development Using Google Test and Google Mock
[Webinar] Qt Test-Driven Development Using Google Test and Google Mock
ICS
 
Basics of Model/View Qt programming
Basics of Model/View Qt programmingBasics of Model/View Qt programming
Basics of Model/View Qt programming
ICS
 
Qt Internationalization
Qt InternationalizationQt Internationalization
Qt Internationalization
ICS
 
Qt for beginners
Qt for beginnersQt for beginners
Qt for beginners
Sergio Shevchenko
 
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
ICS
 
Qt multi threads
Qt multi threadsQt multi threads
Qt multi threads
Ynon Perek
 
Qt Qml
Qt QmlQt Qml
Qt Qml
Steven Song
 
Hello, QML
Hello, QMLHello, QML
Hello, QML
Jack Yang
 
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
Emertxe Information Technologies Pvt Ltd
 
Lessons Learned from Building 100+ C++/Qt/QML Devices
Lessons Learned from Building 100+ C++/Qt/QML DevicesLessons Learned from Building 100+ C++/Qt/QML Devices
Lessons Learned from Building 100+ C++/Qt/QML Devices
ICS
 
Qt Technical Presentation
Qt Technical PresentationQt Technical Presentation
Qt Technical Presentation
Daniel Rocha
 
Qt test framework
Qt test frameworkQt test framework
Qt test framework
ICS
 
Qt programming-using-cpp
Qt programming-using-cppQt programming-using-cpp
Qt programming-using-cpp
Emertxe Information Technologies Pvt Ltd
 
Qt Workshop
Qt WorkshopQt Workshop
Qt Workshop
Johan Thelin
 
Introduction to Qt Creator
Introduction to Qt CreatorIntroduction to Qt Creator
Introduction to Qt Creator
Qt
 
Introduction to Qt programming
Introduction to Qt programmingIntroduction to Qt programming
Introduction to Qt programming
Dragos Tudor Acostachioaie
 
Qt for Beginners Part 3 - QML and Qt Quick
Qt for Beginners Part 3 - QML and Qt QuickQt for Beginners Part 3 - QML and Qt Quick
Qt for Beginners Part 3 - QML and Qt Quick
ICS
 
Best Practices in Qt Quick/QML - Part 4
Best Practices in Qt Quick/QML - Part 4Best Practices in Qt Quick/QML - Part 4
Best Practices in Qt Quick/QML - Part 4
ICS
 
Qt Design Patterns
Qt Design PatternsQt Design Patterns
Qt Design Patterns
Ynon Perek
 
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
ICS
 
[Webinar] Qt Test-Driven Development Using Google Test and Google Mock
[Webinar] Qt Test-Driven Development Using Google Test and Google Mock[Webinar] Qt Test-Driven Development Using Google Test and Google Mock
[Webinar] Qt Test-Driven Development Using Google Test and Google Mock
ICS
 
Basics of Model/View Qt programming
Basics of Model/View Qt programmingBasics of Model/View Qt programming
Basics of Model/View Qt programming
ICS
 
Qt Internationalization
Qt InternationalizationQt Internationalization
Qt Internationalization
ICS
 
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
ICS
 
Qt multi threads
Qt multi threadsQt multi threads
Qt multi threads
Ynon Perek
 
Lessons Learned from Building 100+ C++/Qt/QML Devices
Lessons Learned from Building 100+ C++/Qt/QML DevicesLessons Learned from Building 100+ C++/Qt/QML Devices
Lessons Learned from Building 100+ C++/Qt/QML Devices
ICS
 
Qt Technical Presentation
Qt Technical PresentationQt Technical Presentation
Qt Technical Presentation
Daniel Rocha
 
Qt test framework
Qt test frameworkQt test framework
Qt test framework
ICS
 
Introduction to Qt Creator
Introduction to Qt CreatorIntroduction to Qt Creator
Introduction to Qt Creator
Qt
 

Viewers also liked (20)

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
Pasi Kellokoski
 
[Webinar] 10 Keys to Ensuring Success for Your Next Qt Project
[Webinar] 10 Keys to Ensuring Success for Your Next Qt Project[Webinar] 10 Keys to Ensuring Success for Your Next Qt Project
[Webinar] 10 Keys to Ensuring Success for Your Next Qt Project
ICS
 
Intro to QML / Declarative UI
Intro to QML / Declarative UIIntro to QML / Declarative UI
Intro to QML / Declarative UI
OpenBossa
 
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
ICS
 
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
ICS
 
Qt for beginners part 2 widgets
Qt for beginners part 2   widgetsQt for beginners part 2   widgets
Qt for beginners part 2 widgets
ICS
 
[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
ICS
 
Introduction to Qt
Introduction to QtIntroduction to Qt
Introduction to Qt
Puja Pramudya
 
Practical QML - Key Navigation, Dynamic Language and Theme Change
Practical QML - Key Navigation, Dynamic Language and Theme ChangePractical QML - Key Navigation, Dynamic Language and Theme Change
Practical QML - Key Navigation, Dynamic Language and Theme Change
Burkhard Stubert
 
Integrazione QML / C++
Integrazione QML / C++Integrazione QML / C++
Integrazione QML / C++
Paolo Sereno
 
QThreads: Are You Using Them Wrong?
QThreads: Are You Using Them Wrong? QThreads: Are You Using Them Wrong?
QThreads: Are You Using Them Wrong?
ICS
 
GMock framework
GMock frameworkGMock framework
GMock framework
corehard_by
 
Test driving QML
Test driving QMLTest driving QML
Test driving QML
Artem Marchenko
 
Qt Widget In-Depth
Qt Widget In-DepthQt Widget In-Depth
Qt Widget In-Depth
account inactive
 
Efficient Graphics with Qt
Efficient Graphics with QtEfficient Graphics with Qt
Efficient Graphics with Qt
Ariya Hidayat
 
Case Study: Using Qt to Develop Advanced GUIs & Advanced Visualization Software
Case Study: Using Qt to Develop Advanced GUIs & Advanced Visualization SoftwareCase Study: Using Qt to Develop Advanced GUIs & Advanced Visualization Software
Case Study: Using Qt to Develop Advanced GUIs & Advanced Visualization Software
account inactive
 
State of the Art OpenGL and Qt
State of the Art OpenGL and QtState of the Art OpenGL and Qt
State of the Art OpenGL and Qt
ICS
 
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
ICS
 
What's unique to Qt
What's unique to QtWhat's unique to Qt
What's unique to Qt
Yikei Lu
 
How to Make Your Qt App Look Native
How to Make Your Qt App Look NativeHow to Make Your Qt App Look Native
How to Make Your Qt App Look Native
account inactive
 
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
Pasi Kellokoski
 
[Webinar] 10 Keys to Ensuring Success for Your Next Qt Project
[Webinar] 10 Keys to Ensuring Success for Your Next Qt Project[Webinar] 10 Keys to Ensuring Success for Your Next Qt Project
[Webinar] 10 Keys to Ensuring Success for Your Next Qt Project
ICS
 
Intro to QML / Declarative UI
Intro to QML / Declarative UIIntro to QML / Declarative UI
Intro to QML / Declarative UI
OpenBossa
 
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
ICS
 
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
ICS
 
Qt for beginners part 2 widgets
Qt for beginners part 2   widgetsQt for beginners part 2   widgets
Qt for beginners part 2 widgets
ICS
 
[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
ICS
 
Practical QML - Key Navigation, Dynamic Language and Theme Change
Practical QML - Key Navigation, Dynamic Language and Theme ChangePractical QML - Key Navigation, Dynamic Language and Theme Change
Practical QML - Key Navigation, Dynamic Language and Theme Change
Burkhard Stubert
 
Integrazione QML / C++
Integrazione QML / C++Integrazione QML / C++
Integrazione QML / C++
Paolo Sereno
 
QThreads: Are You Using Them Wrong?
QThreads: Are You Using Them Wrong? QThreads: Are You Using Them Wrong?
QThreads: Are You Using Them Wrong?
ICS
 
Efficient Graphics with Qt
Efficient Graphics with QtEfficient Graphics with Qt
Efficient Graphics with Qt
Ariya Hidayat
 
Case Study: Using Qt to Develop Advanced GUIs & Advanced Visualization Software
Case Study: Using Qt to Develop Advanced GUIs & Advanced Visualization SoftwareCase Study: Using Qt to Develop Advanced GUIs & Advanced Visualization Software
Case Study: Using Qt to Develop Advanced GUIs & Advanced Visualization Software
account inactive
 
State of the Art OpenGL and Qt
State of the Art OpenGL and QtState of the Art OpenGL and Qt
State of the Art OpenGL and Qt
ICS
 
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
ICS
 
What's unique to Qt
What's unique to QtWhat's unique to Qt
What's unique to Qt
Yikei Lu
 
How to Make Your Qt App Look Native
How to Make Your Qt App Look NativeHow to Make Your Qt App Look Native
How to Make Your Qt App Look Native
account inactive
 
Ad

Similar to Best Practices in Qt Quick/QML - Part II (20)

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
ICS
 
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
Janel Heilbrunn
 
Ubuntu app development
Ubuntu app development Ubuntu app development
Ubuntu app development
Xiaoguo Liu
 
Having fun power apps components HandsOn - Power Platform World Tour Copenhag...
Having fun power apps components HandsOn - Power Platform World Tour Copenhag...Having fun power apps components HandsOn - Power Platform World Tour Copenhag...
Having fun power apps components HandsOn - Power Platform World Tour Copenhag...
Rebekka Aalbers-de Jong
 
Javascript dom event
Javascript dom eventJavascript dom event
Javascript dom event
Bunlong Van
 
Angular Data Binding
Angular Data BindingAngular Data Binding
Angular Data Binding
Jennifer Estrada
 
QML\Qt Quick на практике
QML\Qt Quick на практикеQML\Qt Quick на практике
QML\Qt Quick на практике
Platonov Sergey
 
Session iii(server controls)
Session iii(server controls)Session iii(server controls)
Session iii(server controls)
Shrijan Tiwari
 
Build a game with javascript (may 21 atlanta)
Build a game with javascript (may 21 atlanta)Build a game with javascript (may 21 atlanta)
Build a game with javascript (may 21 atlanta)
Thinkful
 
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう
Unity Technologies Japan K.K.
 
Having fun power apps components HandsOn - Power User Days Belgium 2019
Having fun power apps components HandsOn - Power User Days Belgium 2019Having fun power apps components HandsOn - Power User Days Belgium 2019
Having fun power apps components HandsOn - Power User Days Belgium 2019
Rebekka Aalbers-de Jong
 
Session 5#
Session 5#Session 5#
Session 5#
Mohamed Samir
 
Jquery 3
Jquery 3Jquery 3
Jquery 3
Manish Kumar Singh
 
JQuery
JQueryJQuery
JQuery
DevTalk
 
Java Script Basics
Java Script BasicsJava Script Basics
Java Script Basics
Ravi Kumar Hamsa
 
Introduction to VB.Net By William Lacktano.ppt
Introduction to VB.Net By William Lacktano.pptIntroduction to VB.Net By William Lacktano.ppt
Introduction to VB.Net By William Lacktano.ppt
DonWilliam5
 
05.Blend Expression, Transformation & Animation
05.Blend Expression, Transformation & Animation05.Blend Expression, Transformation & Animation
05.Blend Expression, Transformation & Animation
Nguyen Tuan
 
JavaScript!
JavaScript!JavaScript!
JavaScript!
RTigger
 
Lightning chess
Lightning chessLightning chess
Lightning chess
Lieven Juwet
 
WEB PROGRAMMING ANALYSIS
WEB PROGRAMMING ANALYSISWEB PROGRAMMING ANALYSIS
WEB PROGRAMMING ANALYSIS
sweetysweety8
 
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
ICS
 
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
Janel Heilbrunn
 
Ubuntu app development
Ubuntu app development Ubuntu app development
Ubuntu app development
Xiaoguo Liu
 
Having fun power apps components HandsOn - Power Platform World Tour Copenhag...
Having fun power apps components HandsOn - Power Platform World Tour Copenhag...Having fun power apps components HandsOn - Power Platform World Tour Copenhag...
Having fun power apps components HandsOn - Power Platform World Tour Copenhag...
Rebekka Aalbers-de Jong
 
Javascript dom event
Javascript dom eventJavascript dom event
Javascript dom event
Bunlong Van
 
QML\Qt Quick на практике
QML\Qt Quick на практикеQML\Qt Quick на практике
QML\Qt Quick на практике
Platonov Sergey
 
Session iii(server controls)
Session iii(server controls)Session iii(server controls)
Session iii(server controls)
Shrijan Tiwari
 
Build a game with javascript (may 21 atlanta)
Build a game with javascript (may 21 atlanta)Build a game with javascript (may 21 atlanta)
Build a game with javascript (may 21 atlanta)
Thinkful
 
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう
Unity Technologies Japan K.K.
 
Having fun power apps components HandsOn - Power User Days Belgium 2019
Having fun power apps components HandsOn - Power User Days Belgium 2019Having fun power apps components HandsOn - Power User Days Belgium 2019
Having fun power apps components HandsOn - Power User Days Belgium 2019
Rebekka Aalbers-de Jong
 
Introduction to VB.Net By William Lacktano.ppt
Introduction to VB.Net By William Lacktano.pptIntroduction to VB.Net By William Lacktano.ppt
Introduction to VB.Net By William Lacktano.ppt
DonWilliam5
 
05.Blend Expression, Transformation & Animation
05.Blend Expression, Transformation & Animation05.Blend Expression, Transformation & Animation
05.Blend Expression, Transformation & Animation
Nguyen Tuan
 
JavaScript!
JavaScript!JavaScript!
JavaScript!
RTigger
 
WEB PROGRAMMING ANALYSIS
WEB PROGRAMMING ANALYSISWEB PROGRAMMING ANALYSIS
WEB PROGRAMMING ANALYSIS
sweetysweety8
 
Ad

More from ICS (20)

Exploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the FutureExploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the Future
ICS
 
Threat Modeling & Risk Assessment Webinar: A Step-by-Step Example
Threat Modeling & Risk Assessment Webinar: A Step-by-Step ExampleThreat Modeling & Risk Assessment Webinar: A Step-by-Step Example
Threat Modeling & Risk Assessment Webinar: A Step-by-Step Example
ICS
 
8 Mandatory Security Control Categories for Successful Submissions
8 Mandatory Security Control Categories for Successful Submissions8 Mandatory Security Control Categories for Successful Submissions
8 Mandatory Security Control Categories for Successful Submissions
ICS
 
Future-Proofing Embedded Device Capabilities with the Qt 6 Plugin Mechanism.pdf
Future-Proofing Embedded Device Capabilities with the Qt 6 Plugin Mechanism.pdfFuture-Proofing Embedded Device Capabilities with the Qt 6 Plugin Mechanism.pdf
Future-Proofing Embedded Device Capabilities with the Qt 6 Plugin Mechanism.pdf
ICS
 
Choosing an Embedded GUI: Comparative Analysis of UI Frameworks
Choosing an Embedded GUI: Comparative Analysis of UI FrameworksChoosing an Embedded GUI: Comparative Analysis of UI Frameworks
Choosing an Embedded GUI: Comparative Analysis of UI Frameworks
ICS
 
Medical Device Cyber Testing to Meet FDA Requirements
Medical Device Cyber Testing to Meet FDA RequirementsMedical Device Cyber Testing to Meet FDA Requirements
Medical Device Cyber Testing to Meet FDA Requirements
ICS
 
Threat Modeling and Risk Assessment Webinar.pdf
Threat Modeling and Risk Assessment Webinar.pdfThreat Modeling and Risk Assessment Webinar.pdf
Threat Modeling and Risk Assessment Webinar.pdf
ICS
 
Secure-by-Design Using Hardware and Software Protection for FDA Compliance
Secure-by-Design Using Hardware and Software Protection for FDA ComplianceSecure-by-Design Using Hardware and Software Protection for FDA Compliance
Secure-by-Design Using Hardware and Software Protection for FDA Compliance
ICS
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
ICS
 
A Deep Dive into Secure Product Development Frameworks.pdf
A Deep Dive into Secure Product Development Frameworks.pdfA Deep Dive into Secure Product Development Frameworks.pdf
A Deep Dive into Secure Product Development Frameworks.pdf
ICS
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
ICS
 
Practical Advice for FDA’s 510(k) Requirements.pdf
Practical Advice for FDA’s 510(k) Requirements.pdfPractical Advice for FDA’s 510(k) Requirements.pdf
Practical Advice for FDA’s 510(k) Requirements.pdf
ICS
 
Accelerating Development of a Safety-Critical Cobot Welding System with Qt/QM...
Accelerating Development of a Safety-Critical Cobot Welding System with Qt/QM...Accelerating Development of a Safety-Critical Cobot Welding System with Qt/QM...
Accelerating Development of a Safety-Critical Cobot Welding System with Qt/QM...
ICS
 
Overcoming CMake Configuration Issues Webinar
Overcoming CMake Configuration Issues WebinarOvercoming CMake Configuration Issues Webinar
Overcoming CMake Configuration Issues Webinar
ICS
 
Enhancing Quality and Test in Medical Device Design - Part 2.pdf
Enhancing Quality and Test in Medical Device Design - Part 2.pdfEnhancing Quality and Test in Medical Device Design - Part 2.pdf
Enhancing Quality and Test in Medical Device Design - Part 2.pdf
ICS
 
Designing and Managing IoT Devices for Rapid Deployment - Webinar.pdf
Designing and Managing IoT Devices for Rapid Deployment - Webinar.pdfDesigning and Managing IoT Devices for Rapid Deployment - Webinar.pdf
Designing and Managing IoT Devices for Rapid Deployment - Webinar.pdf
ICS
 
Quality and Test in Medical Device Design - Part 1.pdf
Quality and Test in Medical Device Design - Part 1.pdfQuality and Test in Medical Device Design - Part 1.pdf
Quality and Test in Medical Device Design - Part 1.pdf
ICS
 
Creating Digital Twins Using Rapid Development Techniques.pdf
Creating Digital Twins Using Rapid Development Techniques.pdfCreating Digital Twins Using Rapid Development Techniques.pdf
Creating Digital Twins Using Rapid Development Techniques.pdf
ICS
 
Secure Your Medical Devices From the Ground Up
Secure Your Medical Devices From the Ground Up Secure Your Medical Devices From the Ground Up
Secure Your Medical Devices From the Ground Up
ICS
 
Cybersecurity and Software Updates in Medical Devices.pdf
Cybersecurity and Software Updates in Medical Devices.pdfCybersecurity and Software Updates in Medical Devices.pdf
Cybersecurity and Software Updates in Medical Devices.pdf
ICS
 
Exploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the FutureExploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the Future
ICS
 
Threat Modeling & Risk Assessment Webinar: A Step-by-Step Example
Threat Modeling & Risk Assessment Webinar: A Step-by-Step ExampleThreat Modeling & Risk Assessment Webinar: A Step-by-Step Example
Threat Modeling & Risk Assessment Webinar: A Step-by-Step Example
ICS
 
8 Mandatory Security Control Categories for Successful Submissions
8 Mandatory Security Control Categories for Successful Submissions8 Mandatory Security Control Categories for Successful Submissions
8 Mandatory Security Control Categories for Successful Submissions
ICS
 
Future-Proofing Embedded Device Capabilities with the Qt 6 Plugin Mechanism.pdf
Future-Proofing Embedded Device Capabilities with the Qt 6 Plugin Mechanism.pdfFuture-Proofing Embedded Device Capabilities with the Qt 6 Plugin Mechanism.pdf
Future-Proofing Embedded Device Capabilities with the Qt 6 Plugin Mechanism.pdf
ICS
 
Choosing an Embedded GUI: Comparative Analysis of UI Frameworks
Choosing an Embedded GUI: Comparative Analysis of UI FrameworksChoosing an Embedded GUI: Comparative Analysis of UI Frameworks
Choosing an Embedded GUI: Comparative Analysis of UI Frameworks
ICS
 
Medical Device Cyber Testing to Meet FDA Requirements
Medical Device Cyber Testing to Meet FDA RequirementsMedical Device Cyber Testing to Meet FDA Requirements
Medical Device Cyber Testing to Meet FDA Requirements
ICS
 
Threat Modeling and Risk Assessment Webinar.pdf
Threat Modeling and Risk Assessment Webinar.pdfThreat Modeling and Risk Assessment Webinar.pdf
Threat Modeling and Risk Assessment Webinar.pdf
ICS
 
Secure-by-Design Using Hardware and Software Protection for FDA Compliance
Secure-by-Design Using Hardware and Software Protection for FDA ComplianceSecure-by-Design Using Hardware and Software Protection for FDA Compliance
Secure-by-Design Using Hardware and Software Protection for FDA Compliance
ICS
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
ICS
 
A Deep Dive into Secure Product Development Frameworks.pdf
A Deep Dive into Secure Product Development Frameworks.pdfA Deep Dive into Secure Product Development Frameworks.pdf
A Deep Dive into Secure Product Development Frameworks.pdf
ICS
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
ICS
 
Practical Advice for FDA’s 510(k) Requirements.pdf
Practical Advice for FDA’s 510(k) Requirements.pdfPractical Advice for FDA’s 510(k) Requirements.pdf
Practical Advice for FDA’s 510(k) Requirements.pdf
ICS
 
Accelerating Development of a Safety-Critical Cobot Welding System with Qt/QM...
Accelerating Development of a Safety-Critical Cobot Welding System with Qt/QM...Accelerating Development of a Safety-Critical Cobot Welding System with Qt/QM...
Accelerating Development of a Safety-Critical Cobot Welding System with Qt/QM...
ICS
 
Overcoming CMake Configuration Issues Webinar
Overcoming CMake Configuration Issues WebinarOvercoming CMake Configuration Issues Webinar
Overcoming CMake Configuration Issues Webinar
ICS
 
Enhancing Quality and Test in Medical Device Design - Part 2.pdf
Enhancing Quality and Test in Medical Device Design - Part 2.pdfEnhancing Quality and Test in Medical Device Design - Part 2.pdf
Enhancing Quality and Test in Medical Device Design - Part 2.pdf
ICS
 
Designing and Managing IoT Devices for Rapid Deployment - Webinar.pdf
Designing and Managing IoT Devices for Rapid Deployment - Webinar.pdfDesigning and Managing IoT Devices for Rapid Deployment - Webinar.pdf
Designing and Managing IoT Devices for Rapid Deployment - Webinar.pdf
ICS
 
Quality and Test in Medical Device Design - Part 1.pdf
Quality and Test in Medical Device Design - Part 1.pdfQuality and Test in Medical Device Design - Part 1.pdf
Quality and Test in Medical Device Design - Part 1.pdf
ICS
 
Creating Digital Twins Using Rapid Development Techniques.pdf
Creating Digital Twins Using Rapid Development Techniques.pdfCreating Digital Twins Using Rapid Development Techniques.pdf
Creating Digital Twins Using Rapid Development Techniques.pdf
ICS
 
Secure Your Medical Devices From the Ground Up
Secure Your Medical Devices From the Ground Up Secure Your Medical Devices From the Ground Up
Secure Your Medical Devices From the Ground Up
ICS
 
Cybersecurity and Software Updates in Medical Devices.pdf
Cybersecurity and Software Updates in Medical Devices.pdfCybersecurity and Software Updates in Medical Devices.pdf
Cybersecurity and Software Updates in Medical Devices.pdf
ICS
 

Recently uploaded (20)

Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 

Best Practices in Qt Quick/QML - Part II

  • 1. Qt Quick Best Practices Part 2 Langston Ball ICS Consulting Engineer ICS, Inc.
  • 2. Agenda • Creating New Item • State and Transitions • Dynamic Creation of Items
  • 4. Extending Items • Any instance of a QML item is effectively a subclass • Add member properties • Add member functions • Add signals • There is no reason to add signals to an instance
  • 5. Extending Items Rectangle{ Text { id: label property int count: 1 text: “Count = ” + count function incrementCount() { count = count+1 } } Timer { running: true onTriggered: label.incrementCount() } }
  • 6. Property Types • Properties can be almost any type • Basic: int, real, string, date, time, point • Copies are stored • Any valid QML type: Rectangle, Text • These are actually pointers • The “var” type is equivalent to Qvariant • Use explicit types as much as you can • They are faster
  • 7. Property Types Rectangle{ id: button property int anInt: 1 property real aDouble: 50.5 property bool aBool: false property string aString: “” property var anything: 50.5 property list<point> points: [ Qt.point(0,0), Qt.point(100,100) ] }
  • 8. Dividing Code Into Components • Often a devs to put too much code in one QML file • Common issue for all programming languages • QML makes it easy to componentize your code • Component refers to an item that can be instanced multiple times
  • 9. Creating New Items • Simply create a new .qml file • Type is named after the filename • Must begin with a capital letter • Implement • Properties • Signals • Functions
  • 10. Inline Button Code Rectangle{ // Main.qml id: toplevel color: “black” Rectangle { id: button width: 100; height: 50 color: “blue” Text { text: “Click Me” } MouseArea { anchors.fill: parent onPressedChanged: button.color = (pressed) ? “red” : “blue” onClicked: toplevel.color = “white” } } }
  • 11. Componentized Button Rectangle{ // Main.qml id: toplevel color: “black” Button { text: “Click Me” onClicked: toplevel.color = “white” } }
  • 12. Componentized Button Rectangle{ // Button.qml id: button property alias text: label.text signal clicked() color: “blue” width: 100; height: 50 Text { id: label anchors.centerIn: parent } MouseArea{ id: ma anchors.fill: parent onClicked: button.clicked() } }
  • 13. Alias Properties • Proxies properties to child items • Allows hiding of implementation details • Saves memory and binding recalculations
  • 14. Property Scope • Public Scope • All public properties of the root item • Custom properties defined on the root item • Private Scope • All child items and their properties
  • 15. Public Members Rectangle{ // Button.qml id: button property alias text: label.text signal clicked() color: “blue” Text { id: label anchors.centerIn: parent } MouseArea{ id: ma anchors.fill: parent onClicked: button.clicked() } }
  • 16. Private Members Rectangle{ // Button.qml id: button property alias text: label.text signal clicked() color: “blue” Text { id: label anchors.centerIn: parent } MouseArea{ id: ma anchors.fill: parent onClicked: button.clicked() } }
  • 17. Private Properties Rectangle { // Button.qml id: button property alias text: label.text signal clicked() QtObject { id: internal property int centerX: button.width()/2 } Text { x: internal.centerX } }
  • 18. Avoid Inheriting Public Members // Inherit from the basic Item type and hide everything else Item { // Button.qml id: button property alias text: label.text signal clicked() Rectangle { id: background color: “blue” } Text { id: label anchors.centerIn: parent } ... }
  • 20. States • State Machines can make your code “more declarative” • A basic state machine is built into every Item • No parallel states or state history
  • 21. States • Every Item has a states property • States contain • Name • When Clause • List of PropertyChanges{} objects
  • 22. Setting States • Item can be set to a give state two ways • 1) “state” property is set to the name of the State • item.state = “Pressed” • 2) The when clause of the State is true • When clauses must be mutually exclusive • They are evaluated in creation order
  • 23. Button States Item { Rectangle { id: bkg; color: “blue” } MouseArea { id: ma } states: [ State { name: “Pressed” when: ma.pressed PropertyChanges { target: bkg; color: “red” } }, State { name: “Disabled” when: !(ma.enabled) PropertyChanges { target: bkg; color: “grey” } } ] }
  • 24. Default State • The initial bindings are the “Default State” • The name of the default state is “” • Default state is in effect when • No when clauses are satisfied • “state” property is set to “”
  • 25. Properties When in a State • The bindings of a QML document is defined as • The default state bindings • Overlaid with PropertyChanges from the current state • This will save you a ton of typing • States do not need to be unwound • Set common properties in the default state • Avoids writing duplicate PropertyChanges
  • 26. Transitions • Run animations on a state change • Control how properties will change • Qt will automatically interpolate values • Control in which order properties change
  • 27. Transitions [ ... ] transitions: [ Transition { from: “”; to: “Pressed” PropertyAnimation { target: bkg properties: “color” duration: 500 }, Transition { from: “*”; to: “Disabled” PropertyAnimation { target: bkg properties: “color” duration: 250 } ] [ ... ]
  • 28. Transition Defaults • Transition{} defaults to • from: “*”; to: “*” • That Transition will apply to all state changes • PropertyAnimation • When a target is not specified • That animation will apply to all items
  • 29. Button Transition Item { Rectangle { id: bkg; color: “blue” } MouseArea { id: ma } states: [ State { name: “Pressed”; when: ma.pressed PropertyChanges { target: bkg; color: “red” } }, State { name: “Disabled”; when: !(ma.enabled) PropertyChanges { target: bkg; color: “grey” } } ] transitions: [ Transition { PropertyAnimation { properties: “color”; duration: 500 } } ] }
  • 31. Creating Items Dynamically • Procedural Way • Component createObject(parent, bindings) function • Declarative Way • Loader Item • Repeater Item • ListView / GridView Items
  • 32. Procedural Creation Item { id: screen property SettingDialog dialog: undefined Button { text: “Settings...” onClicked: { var component = Qt.createComponent(“SettingsDialog.qml”) screen.dialog = component.createObject(screen, { anchors.centerIn: screen }) screen.dialog.close.connect(screen.destroySettingsDialog) } function destroySettingsDialog() { screen.dialog.destroy() screen.dialog = undefined } }
  • 33. Procedural / Declarative Creation Item { id: screen Button { text: “Settings...” onClicked: { dialogComponent.createObject(screen) } Component { id: dialogComponent SettingsDialog { anchors.centerIn: parent onClose: destroy() } } }
  • 34. Declarative Creation Item { Button { text: “Settings...” onClicked: loader.sourceComponent = dialogComponent Loader { id: loader anchors.fill: parent } Component { id: dialogComponent SettingsDialog { anchors.centerIn: parent onClose: loader.sourceComponent = undefined } } }
  • 35. Creating Multiple Items Item { width: 400; height: 400 color: “black” Grid { x: 5; y:5 rows: 5; columns: 5 Repeater { model: 24 Rectangle { width: 70; height: 70 color: “lightgreen” } } } }
  • 36. Creating Multiple Items Item { width: 400; height: 400 color: “black” Grid { x: 5; y:5 rows: 5; columns: 5 Repeater { model: 24 Rectangle { width: 70; height: 70 color: “lightgreen” Text { anchors.centerIn: parent text: index } } } } }
  • 37. Repeater • Repeaters can use all type of data models • ListModel • JSON Data • property list<type> • QList<QObject*> • QAbstractItemModel • Model data is accessed via attached properties
  • 38. Thank You! Part III: July 23rd, 2015 Http://www.ics.com/webinars Langston Ball ICS Consulting Engineer ICS, Inc.