SlideShare a Scribd company logo
1 of 35
Custom Modern Qt Quick 2
components
2
• Presentation
• Adrien Leravat (France)
• Embedded software engineer
• Adeneo Embedded
• France, Germany (Franckfurt), USA
• BSPs and OS porting to ARM (Linux, Windows,
Android, QNX)
• Embedded software architecture and development
• Mobile expertise (cloud, internet of things)
Introduction
3
Today’s UIs
People expect the best out of UIs
Sensors
Animations
Effects
Graphical
acceleration
Touch
Gestures
Modern
feeling
4
• Reminder: custom components can
be QML files or C++ classes
• QML file: collection of QML
components
• Quick & easy
• Limited to existing components
Your own components
[MyComponent.qml]
Rectangle {
width: 100
height: 100
color: “blue”
MouseArea {
anchors.fill: parent
onPressed: {
log.message(“Pressed !”);
}
}
}
Your own components
5
• Custom Item C++ class
• More effort
• More possibilities
• Custom painting
• Custom events handling
Your own components
[mycomponent.h]
class MyComponent : public QQuickItem {
Q_OBJECT
public:
MyComponent();
mousePressEvent(QMouseEvent*);
};
Plugins and
events
Handling Plugings and events
7
• Gestures part of everyday UIs
• Slide, pinch, rotate
• Now a natural way to interact
• Qt provides different ways to handle multi-touch
• More involving than single touch
Multi-touch
8
• Requirements
• Screen with multi-touch capability (ex:
capacitive screen)
• Appropriate driver
• Qt plugin handling multi-touch events for
Linux (EvdevTouch)
• Enjoy multi-touch events in Qt !
Multi-touch
9
Demo hardware and OS
• Freescale Sabre SDP, i.MX6
DualLite
• eGalax 10” capacitive
touchscreen
• Yocto 1.5, kernel 3.x
Qt side
• EvdevTouch plugin
• -plugin
EvdevTouch:/dev/input/touchscreen0
• PinchArea and custom
components
Multi-touch
 /dev/input/touchscreen0, evtest,
run options
10
• MouseArea
• Single touch
• Handles tap, press, release
• Flickable
• Single touch
• Scroll content
Multi-touch
• PinchArea
• Easy handling of drag,
scale and rotate
• MultiPointTouchArea
• Manual handling of single
touch points and behavior
• Custom QQuickItem class
• setAcceptedMouseButtons
• event / touchEvent
handlers
11
A few tips
Touch events converts to mouse events if not handled
• PinchArea / filters may interfere with MouseArea
“clicked” signal
• Use “pressed” signal
setFiltersChildMouseEvents
• Catch all children events, then filter or let go
grabTouchPoints, setKeepTouchGrab
Multi-touch
Polishing with effects
Animations and
shaders
Polishing with effects
13
• Effects can provides final polish,
or be part of the full experience
• Animating, to improve
user-friendliness
• Blurring UI to
strengthen focus
• Aesthetics and behavior
Polishing with effects
14
• Animations from QML
• Behavior
• PropertyAnimation
• State / Transition animations
Polishing with effects
MyButton {
width: 100
height: 100
color: “blue”
Behavior on x {
NumberAnimation {
duration: 500
easing.type: Easing.OutQuad
}
}
}
15
• Animations from C++ Item class
• QPropertyAnimation
• Same parameters as QML animations
• Needs corresponding Q_PROPERTY
Polishing with effects
QPropertyAnimation *anim = new
QPropertyAnimation();
anim->setTargetObject(this);
anim->setPropertyName(“x”)
anim->setDuration(500);
anim->setEndValue(newXValue);
anim->start();
16
Qt Graphical Effect
• import QtGraphicalEffects 1.0
• GaussianBlur, FastBlur,
RecursiveBlur
• Fade part of the UI, focus on
important parts
• DropShadow, Glow, RectangularGlow
• Makes components stand out
Multitouch
Click me !
OpenGL drawings
Make it faster !
18
• Fluidity and responsiveness are critical
• Challenging on embedded devices
• Since Qt 5, full OpenGL acceleration for QtQuick
• Backend provides graphical acceleration
• Eglfs is the common choice on linux
• MyApp –platform eglfs
Context Context
19
• Qt Quick 1
• QDeclarativeItem
• QDeclarativeItem inherited QGraphicsItem
• paint() method with QPainter
• Qt Quick 2
• QQuickItem
• QQuickItem inherits QObject
• No paint() method !
Qt Quick item class
20
• How to draw QtQuick2 item ?
• QQuickPaintedItem (QQuickItem)
• Implement paint() method (QPainter drawing)
• Convenience class, don’t fully leverage Scene
Graph and OpenGL
• Suited for light components
QQuickPaintedItem
21
• Scene graph
• Relies on Opengl / Opengl ES
• State aware to minimize overhead
• Render thread
• Performs optimizations
• Material sorting
• Ignore obstructed items
Scene graph
Scene
22
• Scene graph nodes
• Each item is internally a
node
• Each node contains all its
children
• A node can be a visible
item, or provide
functionality
• Opacity, transformation
Scene graph
Scene
23
How to leverage Qt Quick2 performances?
• Inherit QQuickItem
• setFlag, ItemHasContents
• Implement updatePaintNode method
• Use Scene Graph classes (QSG*)
• update() to trigger updatePaintNode when
needed
Qt Quick 2 item class
24
• oldNode holds the previous state of the node
• Null until initialized
• Contains its type and hierarchy
• Set its color and geometry
First accelerated item
QSGNode *MyItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
{
QSGSimpleRectNode *n = static_cast<QSGSimpleRectNode *>(oldNode);
if ( ! n ) {
n = new QSGSimpleRectNode();
n->setColor(Qt::red);
}
n->setRect(boundingRect());
return n;
}
25
• Draw exclusively in the render thread, avoid classes other
than QSG*
• Main thread is blocked during rendering, access to items data
is safe
• Newly created QObject-based classes are running on
rendering thread
• Signals targeting main thread will be queued
Caveats
26
QSGNode
QSGTransformNode
QSGOpacityNode
QSGClipNode
QSGGeometryNode
Node Class
Text text
• setMatrix()
• setOpacity()
• setClipRect()
• setMaterial()
• setGeometry()
27
QSGNode
QSGGeometryNode
- Base class of visual elements
- Holds Geometry and materials
QSGSimpleRectNode
- Rectangle, color
QSGSimpleTextureNode
- Rectangle, texture
Node Class
28
QSGGeometryNode
• Geometry (vertices)
• QSGGeometry
• Points, lines, triangles
Geometry node
QSGGeometry *geometry = new QSGGeometry(QSGGeometry::defaultAttributes_Point2D(), 2);
geometry->setDrawingMode(GL_LINES);
geometry->setLineWidth(3);
geometry->vertexDataAsPoint2D()[0].set(0, 0);
geometry->vertexDataAsPoint2D()[1].set(width(), height());
QSGGeometryNode *node = new QSGGeometryNode;
node->setGeometry(geometry);
node->setFlag(QSGNode::OwnsGeometry);
29
QSGGeometryNode
• Material (shader)
• QSGMaterial, QSGFlatColorMaterial,
QSGSimpleMaterialShader
• Vertex and fragment shaders
• Attributes, uniforms
Geometry node
QSGFlatColorMaterial *material = new QSGFlatColorMaterial;
material->setColor(QColor(255, 0, 0));
QSGGeometryNode *node = new QSGGeometryNode;
node->setMaterial(material);
node->setFlag(QSGNode::OwnsMaterial);
30
• Fully leveraging OpenGL acceleration require some work
• Needs some basic knowledge of OpenGL (vertices, textures,
shaders)
• QQuickPaintedItem when performance is not critical
Sum up
Polishing with effects
Accelerometer
Sensors to adapt to user
32
• Platform / hardware specific Qt Sensor plugin
• Support of your sensor may require creating a new
sensor plugin
• Direct access to drivers data
• Handling accelerometer
• QAccelerometer, QAccelerometerReading (based on
QSensor)
Accelerometer
33
• Create your own
• Duplicate one of the existing Qt sensor plugin
(qtbase/plugins/sensors)
• Composed of
• Sensor factory: QSensorPluginInterface,
QSensorBackendFactory
• Sensor: QSensorBackend
• Reimplement start/stop/poll methods
• Open your driver, read and parse
Accelerometer
34
• Reports x, y, z accelerations
• Commonly used to adapt
display to device orientation
• Set accelerationMode to “Gravity”
• Rotate root item, load alternative UI, …
Accelerometer
35
• Qt let you create modern application
• Only needs your finger skills !
• Possibilities aren’t always visible to marketing
and designers…
Final words
 Enlight them
 Enjoy your work
!

More Related Content

Similar to Witekio custom modern qt quick components

Petri Niemi Qt Advanced Part 1
Petri Niemi Qt Advanced Part 1Petri Niemi Qt Advanced Part 1
Petri Niemi Qt Advanced Part 1NokiaAppForum
 
Copy Your Favourite Nokia App with Qt
Copy Your Favourite Nokia App with QtCopy Your Favourite Nokia App with Qt
Copy Your Favourite Nokia App with Qtaccount inactive
 
Best Practices in Qt Quick/QML - Part 1 of 4
Best Practices in Qt Quick/QML - Part 1 of 4Best Practices in Qt Quick/QML - Part 1 of 4
Best Practices in Qt Quick/QML - Part 1 of 4ICS
 
Introduction to QML
Introduction to QMLIntroduction to QML
Introduction to QMLAlan Uthoff
 
Petri Niemi Qt Advanced Part 2
Petri Niemi Qt Advanced Part 2Petri Niemi Qt Advanced Part 2
Petri Niemi Qt Advanced Part 2NokiaAppForum
 
Intro_OpenCV.ppt
Intro_OpenCV.pptIntro_OpenCV.ppt
Intro_OpenCV.pptRithikRaj25
 
Best Practices in Qt Quick/QML - Part I
Best Practices in Qt Quick/QML - Part IBest Practices in Qt Quick/QML - Part I
Best Practices in Qt Quick/QML - Part IICS
 
Introduction to the Qt Quick Scene Graph
Introduction to the Qt Quick Scene GraphIntroduction to the Qt Quick Scene Graph
Introduction to the Qt Quick Scene GraphICS
 
Qt for beginners part 4 doing more
Qt for beginners part 4   doing moreQt for beginners part 4   doing more
Qt for beginners part 4 doing moreICS
 
Qt Graphics View Framework (Qt Developers Meetup Isreal)
Qt Graphics View Framework (Qt Developers Meetup Isreal)Qt Graphics View Framework (Qt Developers Meetup Isreal)
Qt Graphics View Framework (Qt Developers Meetup Isreal)vitalipe
 
Scripting Your Qt Application
Scripting Your Qt ApplicationScripting Your Qt Application
Scripting Your Qt Applicationaccount inactive
 
Fun with QML
Fun with QMLFun with QML
Fun with QMLICS
 
Computer Graphics
Computer GraphicsComputer Graphics
Computer GraphicsAdri Jovin
 

Similar to Witekio custom modern qt quick components (20)

Petri Niemi Qt Advanced Part 1
Petri Niemi Qt Advanced Part 1Petri Niemi Qt Advanced Part 1
Petri Niemi Qt Advanced Part 1
 
Copy Your Favourite Nokia App with Qt
Copy Your Favourite Nokia App with QtCopy Your Favourite Nokia App with Qt
Copy Your Favourite Nokia App with Qt
 
The Future of Qt Widgets
The Future of Qt WidgetsThe Future of Qt Widgets
The Future of Qt Widgets
 
The Future of Qt Widgets
The Future of Qt WidgetsThe Future of Qt Widgets
The Future of Qt Widgets
 
Best Practices in Qt Quick/QML - Part 1 of 4
Best Practices in Qt Quick/QML - Part 1 of 4Best Practices in Qt Quick/QML - Part 1 of 4
Best Practices in Qt Quick/QML - Part 1 of 4
 
Introduction to QML
Introduction to QMLIntroduction to QML
Introduction to QML
 
Cocos2d 소개 - Korea Linux Forum 2014
Cocos2d 소개 - Korea Linux Forum 2014Cocos2d 소개 - Korea Linux Forum 2014
Cocos2d 소개 - Korea Linux Forum 2014
 
Petri Niemi Qt Advanced Part 2
Petri Niemi Qt Advanced Part 2Petri Niemi Qt Advanced Part 2
Petri Niemi Qt Advanced Part 2
 
Intro_OpenCV.ppt
Intro_OpenCV.pptIntro_OpenCV.ppt
Intro_OpenCV.ppt
 
Best Practices in Qt Quick/QML - Part I
Best Practices in Qt Quick/QML - Part IBest Practices in Qt Quick/QML - Part I
Best Practices in Qt Quick/QML - Part I
 
Introduction to the Qt Quick Scene Graph
Introduction to the Qt Quick Scene GraphIntroduction to the Qt Quick Scene Graph
Introduction to the Qt Quick Scene Graph
 
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
 
Qt Graphics View Framework (Qt Developers Meetup Isreal)
Qt Graphics View Framework (Qt Developers Meetup Isreal)Qt Graphics View Framework (Qt Developers Meetup Isreal)
Qt Graphics View Framework (Qt Developers Meetup Isreal)
 
Scripting Your Qt Application
Scripting Your Qt ApplicationScripting Your Qt Application
Scripting Your Qt Application
 
Hello, QML
Hello, QMLHello, QML
Hello, QML
 
Fun with QML
Fun with QMLFun with QML
Fun with QML
 
Core animation
Core animationCore animation
Core animation
 
Computer Graphics
Computer GraphicsComputer Graphics
Computer Graphics
 
CITi - PySide
CITi - PySideCITi - PySide
CITi - PySide
 

More from Witekio

IoT & Embedded systems development
IoT & Embedded systems developmentIoT & Embedded systems development
IoT & Embedded systems developmentWitekio
 
IoT Device Security
IoT Device SecurityIoT Device Security
IoT Device SecurityWitekio
 
Conference Security by Design - Microsoft - Relever les défis de la sécurité ...
Conference Security by Design - Microsoft - Relever les défis de la sécurité ...Conference Security by Design - Microsoft - Relever les défis de la sécurité ...
Conference Security by Design - Microsoft - Relever les défis de la sécurité ...Witekio
 
Conference Security by Design - Gemalto - Security in IoT
Conference Security by Design - Gemalto - Security in IoTConference Security by Design - Gemalto - Security in IoT
Conference Security by Design - Gemalto - Security in IoTWitekio
 
Conference Security by Design - Lacroix Electronics - Comment conçoit on un o...
Conference Security by Design - Lacroix Electronics - Comment conçoit on un o...Conference Security by Design - Lacroix Electronics - Comment conçoit on un o...
Conference Security by Design - Lacroix Electronics - Comment conçoit on un o...Witekio
 
Machine learning - AI
Machine learning - AIMachine learning - AI
Machine learning - AIWitekio
 
Evoca Group - Smart connected coffee vending machine
Evoca Group - Smart connected coffee vending machineEvoca Group - Smart connected coffee vending machine
Evoca Group - Smart connected coffee vending machineWitekio
 
Containers demystified webinar detailed
Containers demystified webinar detailedContainers demystified webinar detailed
Containers demystified webinar detailedWitekio
 
Witekio Corporate presentation H2 2017
Witekio Corporate presentation H2 2017Witekio Corporate presentation H2 2017
Witekio Corporate presentation H2 2017Witekio
 
Why you should join Witekio
Why you should join WitekioWhy you should join Witekio
Why you should join WitekioWitekio
 
Witekio introducing-predictive-maintenance
Witekio introducing-predictive-maintenanceWitekio introducing-predictive-maintenance
Witekio introducing-predictive-maintenanceWitekio
 
System Software Integration, Witekio
System Software Integration, WitekioSystem Software Integration, Witekio
System Software Integration, WitekioWitekio
 
Witekio Corporate Presentation Q42016
Witekio Corporate Presentation Q42016Witekio Corporate Presentation Q42016
Witekio Corporate Presentation Q42016Witekio
 
Continuous Integration for BSP
Continuous Integration for BSPContinuous Integration for BSP
Continuous Integration for BSPWitekio
 
Witekio Qt and Android
Witekio Qt and AndroidWitekio Qt and Android
Witekio Qt and AndroidWitekio
 
Witekio IoT presentation
Witekio IoT presentation Witekio IoT presentation
Witekio IoT presentation Witekio
 
Adeneo Embedded stay tuned
Adeneo Embedded stay tuned Adeneo Embedded stay tuned
Adeneo Embedded stay tuned Witekio
 

More from Witekio (17)

IoT & Embedded systems development
IoT & Embedded systems developmentIoT & Embedded systems development
IoT & Embedded systems development
 
IoT Device Security
IoT Device SecurityIoT Device Security
IoT Device Security
 
Conference Security by Design - Microsoft - Relever les défis de la sécurité ...
Conference Security by Design - Microsoft - Relever les défis de la sécurité ...Conference Security by Design - Microsoft - Relever les défis de la sécurité ...
Conference Security by Design - Microsoft - Relever les défis de la sécurité ...
 
Conference Security by Design - Gemalto - Security in IoT
Conference Security by Design - Gemalto - Security in IoTConference Security by Design - Gemalto - Security in IoT
Conference Security by Design - Gemalto - Security in IoT
 
Conference Security by Design - Lacroix Electronics - Comment conçoit on un o...
Conference Security by Design - Lacroix Electronics - Comment conçoit on un o...Conference Security by Design - Lacroix Electronics - Comment conçoit on un o...
Conference Security by Design - Lacroix Electronics - Comment conçoit on un o...
 
Machine learning - AI
Machine learning - AIMachine learning - AI
Machine learning - AI
 
Evoca Group - Smart connected coffee vending machine
Evoca Group - Smart connected coffee vending machineEvoca Group - Smart connected coffee vending machine
Evoca Group - Smart connected coffee vending machine
 
Containers demystified webinar detailed
Containers demystified webinar detailedContainers demystified webinar detailed
Containers demystified webinar detailed
 
Witekio Corporate presentation H2 2017
Witekio Corporate presentation H2 2017Witekio Corporate presentation H2 2017
Witekio Corporate presentation H2 2017
 
Why you should join Witekio
Why you should join WitekioWhy you should join Witekio
Why you should join Witekio
 
Witekio introducing-predictive-maintenance
Witekio introducing-predictive-maintenanceWitekio introducing-predictive-maintenance
Witekio introducing-predictive-maintenance
 
System Software Integration, Witekio
System Software Integration, WitekioSystem Software Integration, Witekio
System Software Integration, Witekio
 
Witekio Corporate Presentation Q42016
Witekio Corporate Presentation Q42016Witekio Corporate Presentation Q42016
Witekio Corporate Presentation Q42016
 
Continuous Integration for BSP
Continuous Integration for BSPContinuous Integration for BSP
Continuous Integration for BSP
 
Witekio Qt and Android
Witekio Qt and AndroidWitekio Qt and Android
Witekio Qt and Android
 
Witekio IoT presentation
Witekio IoT presentation Witekio IoT presentation
Witekio IoT presentation
 
Adeneo Embedded stay tuned
Adeneo Embedded stay tuned Adeneo Embedded stay tuned
Adeneo Embedded stay tuned
 

Recently uploaded

Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
buds n tech IT solutions
buds n  tech IT                solutionsbuds n  tech IT                solutions
buds n tech IT solutionsmonugehlot87
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsMehedi Hasan Shohan
 

Recently uploaded (20)

Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
buds n tech IT solutions
buds n  tech IT                solutionsbuds n  tech IT                solutions
buds n tech IT solutions
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software Solutions
 

Witekio custom modern qt quick components

  • 1. Custom Modern Qt Quick 2 components
  • 2. 2 • Presentation • Adrien Leravat (France) • Embedded software engineer • Adeneo Embedded • France, Germany (Franckfurt), USA • BSPs and OS porting to ARM (Linux, Windows, Android, QNX) • Embedded software architecture and development • Mobile expertise (cloud, internet of things) Introduction
  • 3. 3 Today’s UIs People expect the best out of UIs Sensors Animations Effects Graphical acceleration Touch Gestures Modern feeling
  • 4. 4 • Reminder: custom components can be QML files or C++ classes • QML file: collection of QML components • Quick & easy • Limited to existing components Your own components [MyComponent.qml] Rectangle { width: 100 height: 100 color: “blue” MouseArea { anchors.fill: parent onPressed: { log.message(“Pressed !”); } } } Your own components
  • 5. 5 • Custom Item C++ class • More effort • More possibilities • Custom painting • Custom events handling Your own components [mycomponent.h] class MyComponent : public QQuickItem { Q_OBJECT public: MyComponent(); mousePressEvent(QMouseEvent*); };
  • 7. 7 • Gestures part of everyday UIs • Slide, pinch, rotate • Now a natural way to interact • Qt provides different ways to handle multi-touch • More involving than single touch Multi-touch
  • 8. 8 • Requirements • Screen with multi-touch capability (ex: capacitive screen) • Appropriate driver • Qt plugin handling multi-touch events for Linux (EvdevTouch) • Enjoy multi-touch events in Qt ! Multi-touch
  • 9. 9 Demo hardware and OS • Freescale Sabre SDP, i.MX6 DualLite • eGalax 10” capacitive touchscreen • Yocto 1.5, kernel 3.x Qt side • EvdevTouch plugin • -plugin EvdevTouch:/dev/input/touchscreen0 • PinchArea and custom components Multi-touch  /dev/input/touchscreen0, evtest, run options
  • 10. 10 • MouseArea • Single touch • Handles tap, press, release • Flickable • Single touch • Scroll content Multi-touch • PinchArea • Easy handling of drag, scale and rotate • MultiPointTouchArea • Manual handling of single touch points and behavior • Custom QQuickItem class • setAcceptedMouseButtons • event / touchEvent handlers
  • 11. 11 A few tips Touch events converts to mouse events if not handled • PinchArea / filters may interfere with MouseArea “clicked” signal • Use “pressed” signal setFiltersChildMouseEvents • Catch all children events, then filter or let go grabTouchPoints, setKeepTouchGrab Multi-touch
  • 12. Polishing with effects Animations and shaders Polishing with effects
  • 13. 13 • Effects can provides final polish, or be part of the full experience • Animating, to improve user-friendliness • Blurring UI to strengthen focus • Aesthetics and behavior Polishing with effects
  • 14. 14 • Animations from QML • Behavior • PropertyAnimation • State / Transition animations Polishing with effects MyButton { width: 100 height: 100 color: “blue” Behavior on x { NumberAnimation { duration: 500 easing.type: Easing.OutQuad } } }
  • 15. 15 • Animations from C++ Item class • QPropertyAnimation • Same parameters as QML animations • Needs corresponding Q_PROPERTY Polishing with effects QPropertyAnimation *anim = new QPropertyAnimation(); anim->setTargetObject(this); anim->setPropertyName(“x”) anim->setDuration(500); anim->setEndValue(newXValue); anim->start();
  • 16. 16 Qt Graphical Effect • import QtGraphicalEffects 1.0 • GaussianBlur, FastBlur, RecursiveBlur • Fade part of the UI, focus on important parts • DropShadow, Glow, RectangularGlow • Makes components stand out Multitouch Click me !
  • 18. 18 • Fluidity and responsiveness are critical • Challenging on embedded devices • Since Qt 5, full OpenGL acceleration for QtQuick • Backend provides graphical acceleration • Eglfs is the common choice on linux • MyApp –platform eglfs Context Context
  • 19. 19 • Qt Quick 1 • QDeclarativeItem • QDeclarativeItem inherited QGraphicsItem • paint() method with QPainter • Qt Quick 2 • QQuickItem • QQuickItem inherits QObject • No paint() method ! Qt Quick item class
  • 20. 20 • How to draw QtQuick2 item ? • QQuickPaintedItem (QQuickItem) • Implement paint() method (QPainter drawing) • Convenience class, don’t fully leverage Scene Graph and OpenGL • Suited for light components QQuickPaintedItem
  • 21. 21 • Scene graph • Relies on Opengl / Opengl ES • State aware to minimize overhead • Render thread • Performs optimizations • Material sorting • Ignore obstructed items Scene graph Scene
  • 22. 22 • Scene graph nodes • Each item is internally a node • Each node contains all its children • A node can be a visible item, or provide functionality • Opacity, transformation Scene graph Scene
  • 23. 23 How to leverage Qt Quick2 performances? • Inherit QQuickItem • setFlag, ItemHasContents • Implement updatePaintNode method • Use Scene Graph classes (QSG*) • update() to trigger updatePaintNode when needed Qt Quick 2 item class
  • 24. 24 • oldNode holds the previous state of the node • Null until initialized • Contains its type and hierarchy • Set its color and geometry First accelerated item QSGNode *MyItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) { QSGSimpleRectNode *n = static_cast<QSGSimpleRectNode *>(oldNode); if ( ! n ) { n = new QSGSimpleRectNode(); n->setColor(Qt::red); } n->setRect(boundingRect()); return n; }
  • 25. 25 • Draw exclusively in the render thread, avoid classes other than QSG* • Main thread is blocked during rendering, access to items data is safe • Newly created QObject-based classes are running on rendering thread • Signals targeting main thread will be queued Caveats
  • 26. 26 QSGNode QSGTransformNode QSGOpacityNode QSGClipNode QSGGeometryNode Node Class Text text • setMatrix() • setOpacity() • setClipRect() • setMaterial() • setGeometry()
  • 27. 27 QSGNode QSGGeometryNode - Base class of visual elements - Holds Geometry and materials QSGSimpleRectNode - Rectangle, color QSGSimpleTextureNode - Rectangle, texture Node Class
  • 28. 28 QSGGeometryNode • Geometry (vertices) • QSGGeometry • Points, lines, triangles Geometry node QSGGeometry *geometry = new QSGGeometry(QSGGeometry::defaultAttributes_Point2D(), 2); geometry->setDrawingMode(GL_LINES); geometry->setLineWidth(3); geometry->vertexDataAsPoint2D()[0].set(0, 0); geometry->vertexDataAsPoint2D()[1].set(width(), height()); QSGGeometryNode *node = new QSGGeometryNode; node->setGeometry(geometry); node->setFlag(QSGNode::OwnsGeometry);
  • 29. 29 QSGGeometryNode • Material (shader) • QSGMaterial, QSGFlatColorMaterial, QSGSimpleMaterialShader • Vertex and fragment shaders • Attributes, uniforms Geometry node QSGFlatColorMaterial *material = new QSGFlatColorMaterial; material->setColor(QColor(255, 0, 0)); QSGGeometryNode *node = new QSGGeometryNode; node->setMaterial(material); node->setFlag(QSGNode::OwnsMaterial);
  • 30. 30 • Fully leveraging OpenGL acceleration require some work • Needs some basic knowledge of OpenGL (vertices, textures, shaders) • QQuickPaintedItem when performance is not critical Sum up
  • 32. 32 • Platform / hardware specific Qt Sensor plugin • Support of your sensor may require creating a new sensor plugin • Direct access to drivers data • Handling accelerometer • QAccelerometer, QAccelerometerReading (based on QSensor) Accelerometer
  • 33. 33 • Create your own • Duplicate one of the existing Qt sensor plugin (qtbase/plugins/sensors) • Composed of • Sensor factory: QSensorPluginInterface, QSensorBackendFactory • Sensor: QSensorBackend • Reimplement start/stop/poll methods • Open your driver, read and parse Accelerometer
  • 34. 34 • Reports x, y, z accelerations • Commonly used to adapt display to device orientation • Set accelerationMode to “Gravity” • Rotate root item, load alternative UI, … Accelerometer
  • 35. 35 • Qt let you create modern application • Only needs your finger skills ! • Possibilities aren’t always visible to marketing and designers… Final words  Enlight them  Enjoy your work !