SlideShare a Scribd company logo
2
Most read
9
Most read
©Integrated Computer Solutions Inc. www.ics.com
Introduction to Qt Quick
Scene Graph
Vy Duong, Integrated Computer Solutions
Visit us at http://www.ics.com
Produced by Integrated Computer Solutions
Material based on Qt 5.12
1
©Integrated Computer Solutions Inc. www.ics.com
About ICS
ICS Designs User Experiences and Develops Software for
Connected Devices
• Largest source of independent Qt expertise in North America since 2002
• Headquartered in Waltham, MA with offices in California, Canada, Europe
• Includes Boston UX, ICS’ UX design division
• Embedded, touchscreen, mobile and desktop applications
• Exclusive Open Enrollment Training Partner in North America
2
©Integrated Computer Solutions Inc. www.ics.com
UX/UI Design and Development for Connected
Devices Across Many Industries
3
©Integrated Computer Solutions Inc. www.ics.com
Agenda
● What is a Qt Quick Scene Graph?
● What are the benefits?
● When to use it?
● What is provided by Qt?
4
©Integrated Computer Solutions Inc. www.ics.com
What is a Qt Quick Scene Graph?
● A node tree
● Graphical representation of the Item scene
● Contains enough information to render all the items
● Node do not contain any active drawing code or the paint() function
● Node tree is mostly built internally by the Qt Quick QML types, it is possible for
users to add complete subtrees in C++
5
©Integrated Computer Solutions Inc. www.ics.com 6
©Integrated Computer Solutions Inc. www.ics.com
What are the benefits?
● Scene rendering can be retained between frames
● The complete set of items to render is known before rendering begins
● Enables batch rendering to minimize state changes and discarding of
obscured items
7
©Integrated Computer Solutions Inc. www.ics.com
When to use it?
● Performance is impaired by normal drawing techniques
● A need for batch rendering of the items
8
Qt Quick 1 vs Qt Quick 2
Qt Quick 1
● uses QGraphicsView and QPainter for rendering
Qt Quick 2
● Uses QWindow and QOpenGL* for rendering
©Integrated Computer Solutions Inc. www.ics.com
What is provided by Qt?
QSGGeometryNode Used for all rendered content in the scene graph
QSGNode The base class for all nodes in the scene graph
QSGClipNode Implements the clipping functionality in the scene graph
QSGOpacityNode Used to change opacity of nodes
QSGTransformNode Implements transformations in the scene graph
9
©Integrated Computer Solutions Inc. www.ics.com
IMPORTANT NOTE!
● Custom Nodes are added to scene graph by subclassing
QQuickItem::updatePaintNode()
● Setting the QQuickItem::ItemHasContents
10
class MySGExampleItem : public QQuickItem{
public:
MyRect(){
setFlag(ItemHasContents);
}
QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)override{
// Node Codes
}
}
©Integrated Computer Solutions Inc. www.ics.com
QSGGeometryNode
● Consists of geometry and material
● Geometry defines the mesh, the vertices and their structure
● Material defines how the shape is filled
● Uses QSGGeometry for defining geometry
11
©Integrated Computer Solutions Inc. www.ics.com
QSGGeometryNode
QSGGeometry *geometryLine = new
QSGGeometry(QSGGeometry::defaultAttributes_Point2D(), 2);
geometryLine->setDrawingMode(QSGGeometry::DrawLines);
geometryLine->setLineWidth(3);
geometryLine->vertexDataAsPoint2D()[0].set(10, height()/2); // start point 1,1
geometryLine->vertexDataAsPoint2D()[1].set(50, height()); // end point 50, 1
QSGFlatColorMaterial *materialLine = new QSGFlatColorMaterial;
materialLine->setColor(QColor(255, 0, 0));
QSGGeometryNode *node = new QSGGeometryNode;
node->setGeometry(geometryLine);
node->setFlag(QSGNode::OwnsGeometry);
node->setMaterial(materialLine);
node->setFlag(QSGNode::OwnsMaterial);
rootScaleNode->appendChildNode(node);
12
©Integrated Computer Solutions Inc. www.ics.com
QSGNode
● The base class for all nodes in the scene graph
● Children nodes can be added by using:
● void QSGNode::appendChildNode(QSGNode *node) - append to the end of list
● void QSGNode::prependChildNode(QSGNode *node) - add to the beginning of list
● void QSGNode::insertChildNodeAfter(QSGNode *node, QSGNode *after) - insert after a node
● void QSGNode::insertChildNodeBefore(QSGNode *node, QSGNode *before) - insert before a node
● Order of children node matters
● Can mark nodes "Dirty"
13
©Integrated Computer Solutions Inc. www.ics.com
QSGClipNode
● Implements the clipping functionality in the scene graph
● Derives from QSGBasicGeometryNode
● void QSGBasicGeometryNode::setGeometry(QSGGeometry *geometry)
● void QSGClipNode::setClipRect(const QRectF &rect)
● void QSGClipNode::setIsRectangular(bool rectHint)
14
QSGClipNode * clipNode = new QSGClipNode;
clipNode->setClipRect(QRectF(0,0, width(), 60));
clipNode->setIsRectangular(true);
clipNode->appendChildNode(new
QSGSimpleRectNode(QRectF(45,30, width(), height()), Qt::red));
rootScaleNode->appendChildNode(clipNode);
©Integrated Computer Solutions Inc. www.ics.com
QSGOpacityNode
● Used to change the opacity of nodes
● void QSGOpacityNode::setOpacity(qreal opacity)
15
QSGOpacityNode * opacityNode = new QSGOpacityNode;
opacityNode->setOpacity(0.20);
opacityNode->appendChildNode(
new QSGSimpleRectNode(QRectF(0,0, 50, 50), Qt::red)
);
rootScaleNode->appendChildNode(opacityNode);
©Integrated Computer Solutions Inc. www.ics.com
QSGTransformNode
● Implement transformation in the scene graph
16
// transformation example:
QMatrix4x4 scaleMatrix;
scaleMatrix.scale(0.5);
QSGTransformNode *transformNode = new QSGTransformNode;
transformNode->setMatrix(scaleMatrix);
transformNode->appendChildNode(new QSGSimpleRectNode(QRectF(0,0, width(),
height()), Qt::black));
rootScaleNode->appendChildNode(transformNode);
©Integrated Computer Solutions Inc. www.ics.com 17
©Integrated Computer Solutions Inc. www.ics.com
Thank you!
18
Any questions?

More Related Content

PDF
Best Practices in Qt Quick/QML - Part 1 of 4
 
PDF
Best Practices in Qt Quick/QML - Part III
 
PDF
Lessons Learned from Building 100+ C++/Qt/QML Devices
 
PDF
In-Depth Model/View with QML
 
PPTX
Introduction to Qt
PDF
Qt Application Programming with C++ - Part 1
PPTX
Best Practices in Qt Quick/QML - Part I
 
PDF
Best Practices in Qt Quick/QML - Part II
 
Best Practices in Qt Quick/QML - Part 1 of 4
 
Best Practices in Qt Quick/QML - Part III
 
Lessons Learned from Building 100+ C++/Qt/QML Devices
 
In-Depth Model/View with QML
 
Introduction to Qt
Qt Application Programming with C++ - Part 1
Best Practices in Qt Quick/QML - Part I
 
Best Practices in Qt Quick/QML - Part II
 

What's hot (20)

PPTX
Qt for beginners part 1 overview and key concepts
 
PDF
Best Practices in Qt Quick/QML - Part IV
 
PPTX
Qt Framework Events Signals Threads
PDF
Qt for Beginners Part 3 - QML and Qt Quick
 
PDF
Best Practices in Qt Quick/QML - Part 4
 
PDF
Introduction to QML
PDF
QVariant, QObject — Qt's not just for GUI development
 
PDF
Best Practices in Qt Quick/QML - Part 3
 
PDF
Basics of Model/View Qt programming
 
PDF
PDF
Introduction to Qt Creator
 
PDF
BuildKitの概要と最近の機能
PDF
Meet Qt 6.0
 
PDF
Introduction to Qt programming
PDF
関数プログラミング入門
PPTX
Hello, QML
PDF
Java開発の強力な相棒として今すぐ使えるGroovy
PDF
Introduction to the Qt State Machine Framework using Qt 6
 
PDF
TypeScript - An Introduction
PPTX
C#とILとネイティブと
Qt for beginners part 1 overview and key concepts
 
Best Practices in Qt Quick/QML - Part IV
 
Qt Framework Events Signals Threads
Qt for Beginners Part 3 - QML and Qt Quick
 
Best Practices in Qt Quick/QML - Part 4
 
Introduction to QML
QVariant, QObject — Qt's not just for GUI development
 
Best Practices in Qt Quick/QML - Part 3
 
Basics of Model/View Qt programming
 
Introduction to Qt Creator
 
BuildKitの概要と最近の機能
Meet Qt 6.0
 
Introduction to Qt programming
関数プログラミング入門
Hello, QML
Java開発の強力な相棒として今すぐ使えるGroovy
Introduction to the Qt State Machine Framework using Qt 6
 
TypeScript - An Introduction
C#とILとネイティブと
Ad

Similar to Introduction to the Qt Quick Scene Graph (20)

PDF
“ONNX and Python to C++: State-of-the-art Graph Compilation,” a Presentation ...
PDF
Qt for beginners part 4 doing more
 
PDF
Porting Motif Applications to Qt - Webinar
 
PDF
Porting Motif Applications to Qt - Webinar
PPTX
Untitled presentation(4)
PPTX
Qt coin3d soqt
PDF
Deep Learning Edge
PPTX
Trident International Graphics Workshop 2014 1/5
PPT
Qt Programming on TI Processors
PDF
Network programming with Qt (C++)
PDF
Qt for Python
 
PDF
下午3 intel fenghaitao_mee_go api and application development
PDF
writing-custom-qtquickcomponents-QtCon.pdf
PDF
Cocos2d 소개 - Korea Linux Forum 2014
PDF
Necessitas - Qt on Android - from FSCONS 2011
PDF
Villar presentation.pdf
PPTX
Cocos2d for beginners
PDF
Дмитрий Вовк: Векторизация кода под мобильные платформы
PDF
Qt 6 Chat - Are You Ready?
 
PDF
Angular 2 - Core Concepts
“ONNX and Python to C++: State-of-the-art Graph Compilation,” a Presentation ...
Qt for beginners part 4 doing more
 
Porting Motif Applications to Qt - Webinar
 
Porting Motif Applications to Qt - Webinar
Untitled presentation(4)
Qt coin3d soqt
Deep Learning Edge
Trident International Graphics Workshop 2014 1/5
Qt Programming on TI Processors
Network programming with Qt (C++)
Qt for Python
 
下午3 intel fenghaitao_mee_go api and application development
writing-custom-qtquickcomponents-QtCon.pdf
Cocos2d 소개 - Korea Linux Forum 2014
Necessitas - Qt on Android - from FSCONS 2011
Villar presentation.pdf
Cocos2d for beginners
Дмитрий Вовк: Векторизация кода под мобильные платформы
Qt 6 Chat - Are You Ready?
 
Angular 2 - Core Concepts
Ad

More from ICS (20)

PDF
Understanding the EU Cyber Resilience Act
 
PDF
Porting Qt 5 QML Modules to Qt 6 Webinar
 
PDF
Medical Device Cybersecurity Threat & Risk Scoring
 
PDF
Exploring Wayland: A Modern Display Server for the Future
 
PDF
Threat Modeling & Risk Assessment Webinar: A Step-by-Step Example
 
PDF
8 Mandatory Security Control Categories for Successful Submissions
 
PDF
Future-Proofing Embedded Device Capabilities with the Qt 6 Plugin Mechanism.pdf
 
PDF
Choosing an Embedded GUI: Comparative Analysis of UI Frameworks
 
PDF
Medical Device Cyber Testing to Meet FDA Requirements
 
PDF
Threat Modeling and Risk Assessment Webinar.pdf
 
PDF
Secure-by-Design Using Hardware and Software Protection for FDA Compliance
 
PDF
Webinar On-Demand: Using Flutter for Embedded
 
PDF
A Deep Dive into Secure Product Development Frameworks.pdf
 
PDF
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
PDF
Practical Advice for FDA’s 510(k) Requirements.pdf
 
PDF
Accelerating Development of a Safety-Critical Cobot Welding System with Qt/QM...
 
PDF
Overcoming CMake Configuration Issues Webinar
 
PDF
Enhancing Quality and Test in Medical Device Design - Part 2.pdf
 
PDF
Designing and Managing IoT Devices for Rapid Deployment - Webinar.pdf
 
PDF
Quality and Test in Medical Device Design - Part 1.pdf
 
Understanding the EU Cyber Resilience Act
 
Porting Qt 5 QML Modules to Qt 6 Webinar
 
Medical Device Cybersecurity Threat & Risk Scoring
 
Exploring Wayland: A Modern Display Server for the Future
 
Threat Modeling & Risk Assessment Webinar: A Step-by-Step Example
 
8 Mandatory Security Control Categories for Successful Submissions
 
Future-Proofing Embedded Device Capabilities with the Qt 6 Plugin Mechanism.pdf
 
Choosing an Embedded GUI: Comparative Analysis of UI Frameworks
 
Medical Device Cyber Testing to Meet FDA Requirements
 
Threat Modeling and Risk Assessment Webinar.pdf
 
Secure-by-Design Using Hardware and Software Protection for FDA Compliance
 
Webinar On-Demand: Using Flutter for Embedded
 
A Deep Dive into Secure Product Development Frameworks.pdf
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Practical Advice for FDA’s 510(k) Requirements.pdf
 
Accelerating Development of a Safety-Critical Cobot Welding System with Qt/QM...
 
Overcoming CMake Configuration Issues Webinar
 
Enhancing Quality and Test in Medical Device Design - Part 2.pdf
 
Designing and Managing IoT Devices for Rapid Deployment - Webinar.pdf
 
Quality and Test in Medical Device Design - Part 1.pdf
 

Recently uploaded (20)

PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
cuic standard and advanced reporting.pdf
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Encapsulation theory and applications.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
Big Data Technologies - Introduction.pptx
PDF
Modernizing your data center with Dell and AMD
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PPTX
Cloud computing and distributed systems.
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Machine learning based COVID-19 study performance prediction
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Dropbox Q2 2025 Financial Results & Investor Presentation
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Review of recent advances in non-invasive hemoglobin estimation
cuic standard and advanced reporting.pdf
MYSQL Presentation for SQL database connectivity
Mobile App Security Testing_ A Comprehensive Guide.pdf
Encapsulation theory and applications.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Big Data Technologies - Introduction.pptx
Modernizing your data center with Dell and AMD
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Cloud computing and distributed systems.
Chapter 3 Spatial Domain Image Processing.pdf
Network Security Unit 5.pdf for BCA BBA.
Per capita expenditure prediction using model stacking based on satellite ima...
Building Integrated photovoltaic BIPV_UPV.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Unlocking AI with Model Context Protocol (MCP)
Machine learning based COVID-19 study performance prediction
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows

Introduction to the Qt Quick Scene Graph

  • 1. ©Integrated Computer Solutions Inc. www.ics.com Introduction to Qt Quick Scene Graph Vy Duong, Integrated Computer Solutions Visit us at http://www.ics.com Produced by Integrated Computer Solutions Material based on Qt 5.12 1
  • 2. ©Integrated Computer Solutions Inc. www.ics.com About ICS ICS Designs User Experiences and Develops Software for Connected Devices • Largest source of independent Qt expertise in North America since 2002 • Headquartered in Waltham, MA with offices in California, Canada, Europe • Includes Boston UX, ICS’ UX design division • Embedded, touchscreen, mobile and desktop applications • Exclusive Open Enrollment Training Partner in North America 2
  • 3. ©Integrated Computer Solutions Inc. www.ics.com UX/UI Design and Development for Connected Devices Across Many Industries 3
  • 4. ©Integrated Computer Solutions Inc. www.ics.com Agenda ● What is a Qt Quick Scene Graph? ● What are the benefits? ● When to use it? ● What is provided by Qt? 4
  • 5. ©Integrated Computer Solutions Inc. www.ics.com What is a Qt Quick Scene Graph? ● A node tree ● Graphical representation of the Item scene ● Contains enough information to render all the items ● Node do not contain any active drawing code or the paint() function ● Node tree is mostly built internally by the Qt Quick QML types, it is possible for users to add complete subtrees in C++ 5
  • 6. ©Integrated Computer Solutions Inc. www.ics.com 6
  • 7. ©Integrated Computer Solutions Inc. www.ics.com What are the benefits? ● Scene rendering can be retained between frames ● The complete set of items to render is known before rendering begins ● Enables batch rendering to minimize state changes and discarding of obscured items 7
  • 8. ©Integrated Computer Solutions Inc. www.ics.com When to use it? ● Performance is impaired by normal drawing techniques ● A need for batch rendering of the items 8 Qt Quick 1 vs Qt Quick 2 Qt Quick 1 ● uses QGraphicsView and QPainter for rendering Qt Quick 2 ● Uses QWindow and QOpenGL* for rendering
  • 9. ©Integrated Computer Solutions Inc. www.ics.com What is provided by Qt? QSGGeometryNode Used for all rendered content in the scene graph QSGNode The base class for all nodes in the scene graph QSGClipNode Implements the clipping functionality in the scene graph QSGOpacityNode Used to change opacity of nodes QSGTransformNode Implements transformations in the scene graph 9
  • 10. ©Integrated Computer Solutions Inc. www.ics.com IMPORTANT NOTE! ● Custom Nodes are added to scene graph by subclassing QQuickItem::updatePaintNode() ● Setting the QQuickItem::ItemHasContents 10 class MySGExampleItem : public QQuickItem{ public: MyRect(){ setFlag(ItemHasContents); } QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)override{ // Node Codes } }
  • 11. ©Integrated Computer Solutions Inc. www.ics.com QSGGeometryNode ● Consists of geometry and material ● Geometry defines the mesh, the vertices and their structure ● Material defines how the shape is filled ● Uses QSGGeometry for defining geometry 11
  • 12. ©Integrated Computer Solutions Inc. www.ics.com QSGGeometryNode QSGGeometry *geometryLine = new QSGGeometry(QSGGeometry::defaultAttributes_Point2D(), 2); geometryLine->setDrawingMode(QSGGeometry::DrawLines); geometryLine->setLineWidth(3); geometryLine->vertexDataAsPoint2D()[0].set(10, height()/2); // start point 1,1 geometryLine->vertexDataAsPoint2D()[1].set(50, height()); // end point 50, 1 QSGFlatColorMaterial *materialLine = new QSGFlatColorMaterial; materialLine->setColor(QColor(255, 0, 0)); QSGGeometryNode *node = new QSGGeometryNode; node->setGeometry(geometryLine); node->setFlag(QSGNode::OwnsGeometry); node->setMaterial(materialLine); node->setFlag(QSGNode::OwnsMaterial); rootScaleNode->appendChildNode(node); 12
  • 13. ©Integrated Computer Solutions Inc. www.ics.com QSGNode ● The base class for all nodes in the scene graph ● Children nodes can be added by using: ● void QSGNode::appendChildNode(QSGNode *node) - append to the end of list ● void QSGNode::prependChildNode(QSGNode *node) - add to the beginning of list ● void QSGNode::insertChildNodeAfter(QSGNode *node, QSGNode *after) - insert after a node ● void QSGNode::insertChildNodeBefore(QSGNode *node, QSGNode *before) - insert before a node ● Order of children node matters ● Can mark nodes "Dirty" 13
  • 14. ©Integrated Computer Solutions Inc. www.ics.com QSGClipNode ● Implements the clipping functionality in the scene graph ● Derives from QSGBasicGeometryNode ● void QSGBasicGeometryNode::setGeometry(QSGGeometry *geometry) ● void QSGClipNode::setClipRect(const QRectF &rect) ● void QSGClipNode::setIsRectangular(bool rectHint) 14 QSGClipNode * clipNode = new QSGClipNode; clipNode->setClipRect(QRectF(0,0, width(), 60)); clipNode->setIsRectangular(true); clipNode->appendChildNode(new QSGSimpleRectNode(QRectF(45,30, width(), height()), Qt::red)); rootScaleNode->appendChildNode(clipNode);
  • 15. ©Integrated Computer Solutions Inc. www.ics.com QSGOpacityNode ● Used to change the opacity of nodes ● void QSGOpacityNode::setOpacity(qreal opacity) 15 QSGOpacityNode * opacityNode = new QSGOpacityNode; opacityNode->setOpacity(0.20); opacityNode->appendChildNode( new QSGSimpleRectNode(QRectF(0,0, 50, 50), Qt::red) ); rootScaleNode->appendChildNode(opacityNode);
  • 16. ©Integrated Computer Solutions Inc. www.ics.com QSGTransformNode ● Implement transformation in the scene graph 16 // transformation example: QMatrix4x4 scaleMatrix; scaleMatrix.scale(0.5); QSGTransformNode *transformNode = new QSGTransformNode; transformNode->setMatrix(scaleMatrix); transformNode->appendChildNode(new QSGSimpleRectNode(QRectF(0,0, width(), height()), Qt::black)); rootScaleNode->appendChildNode(transformNode);
  • 17. ©Integrated Computer Solutions Inc. www.ics.com 17
  • 18. ©Integrated Computer Solutions Inc. www.ics.com Thank you! 18 Any questions?