SlideShare a Scribd company logo
vitali.pe@gmail.com
vitali.p@volicon.com

QT Graphics View Framework
[vitali]: ~/qt-secene-demos/ >> python cool_intro.py
Traceback (most recent call last):
File "PySideexamplesopengloverpainting.py", line 198, in paintEvent
self.resizeGL(self.width(), self.height())
File "PySideexamplesopengloverpainting.py", line 227, in resizeGL
glViewport(((width - side) / 2), ((height - side) / 2), side, side)
ctypes.ArgumentError: argument 1: <class 'TypeError'>: wrong type
Traceback (most recent call last):
File "PySideexamplesopengloverpainting.py", line 198, in paintEvent
self.resizeGL(self.width(), self.height())
File "PySideexamplesopengloverpainting.py", line 227, in resizeGL
glViewport(((width - side) / 2), ((height - side) / 2), side, side)
ctypes.ArgumentError: argument 1: <class 'TypeError'>: wrong type
Soo... QGraphicsScene..
Basically it’s a canvas library on (a lot of) steroids.

Features:
Model/View Architecture.
It’s own event system (not signals & slots)
Low level rendering (with QPainter)
Input Handling (mouse & keyboard)
Simple animation
Support for embedding QWidgets
Collision detection
Drag & Drop
….
Demo App
https://bitbucket.org/vitalipe/sggle/wiki/Home
Architecture Overview
Only 3 Basic components item(s), that are added to the scene,
and one or more views to display the
scene.

View

View

Graphics Scene

Item
Item

VIew
Item
This is the actual QWidget, that is added to
your layout...

Item
Item
First, lets talk about rendering widgets in QT

●
●
●

Widget render themselves by overriding paintEvent()
QT uses the “painter's algorithm”
Any Widget can be hardware accelerated.

paintEvent()

1
paintEvent()

2

3
paintEvent()

4
paintEvent()
Ok… so what about graphics scene?
The graphics scene, has a different more flexible
and optimized API for drawing and transforms , but
the same principle apply….
1
2
Also up until QT 5 , QML widgets where
implemented on top of QGraphicsView

3

4
Rendering in Qt 4.8
QML
Via QGraphicsView

Qt Webkit

QWidget

QPainter

OpenGL
Renderer

Software
Renderer
Rendering in Qt 5

QML

Qt Webkit

QWidget

QPainter

SceneGraph

OpenGL
Renderer

Software
Renderer
Why? you ask...
Well… because painter’s algorithm will fuckup any
OpenGL based rendering pipeline!

QML

Z-Buffering FTW!
SceneGraph

Yes you can get away with it on desktops when
you're not developing AAA games… but Qt Quick
is for moblie remember ?

OpenGL
Renderer
The Item, View & Scene

QGraphicsScene:
●
●
●
●

itemAt(x : float, y : float)
addItem(item : QGraphicsItem)
addPixmap( pixmap : QPixmap)
selectedItems()
...

Providing an interface for managing items
Propagating events to each item
Managing item state, such as selection and focus handling
Providing (untransformed) rendering functionality.
The Item, View & Scene

QGraphicsItem:
●
●
●
●
●
●

setPos(pos : QPointF)
setTransform(t : QTransform)
setEnabled( enabled : bool)
childItems()
...

Mouse and keyboard input events
Drag and drop
Parent-child relationships.
Collision detection.
Has many many built-in sub types
If you want to implement layers effects, etc… you need a custom item
The Item, View & Scene

QGraphicsView:
●
●
●
●
●

mapFromScene(pos : QPointF)
mapToScene(pos : QPointF)
centerOn(pos : QPointF)
setTransform(t : QTransform)
...

Visualizes the contents of a scene.
Is a subclass of QWidget
A scene can have multiple views attached to it.
Translates keyboard and mouse events to scene events
Has it’s own transform matrix.
Questions ?

More Related Content

PDF
Petri Niemi Qt Advanced Part 1
PDF
Scripting Your Qt Application
PDF
Qt Animation
PDF
The Next Generation Qt Item Views
PDF
The Future of Qt Widgets
PDF
Qt and QML performance tips & tricks for Qt 4.7
PDF
QVariant, QObject — Qt's not just for GUI development
 
PDF
Meet the Widgets: Another Way to Implement UI
 
Petri Niemi Qt Advanced Part 1
Scripting Your Qt Application
Qt Animation
The Next Generation Qt Item Views
The Future of Qt Widgets
Qt and QML performance tips & tricks for Qt 4.7
QVariant, QObject — Qt's not just for GUI development
 
Meet the Widgets: Another Way to Implement UI
 

What's hot (17)

PDF
Special Effects with Qt Graphics View
PDF
Qt for Beginners Part 3 - QML and Qt Quick
 
PDF
QThreads: Are You Using Them Wrong?
 
PDF
Convert Your Legacy OpenGL Code to Modern OpenGL with Qt
 
PDF
Qt on Real Time Operating Systems
PDF
Qt State Machine Framework
PDF
Copy Your Favourite Nokia App with Qt
PDF
Best Practices in Qt Quick/QML - Part 1 of 4
 
PDF
Necessitas - Qt on Android - from FSCONS 2011
PDF
Building the QML Run-time
ODP
Qt Workshop
PDF
Qt Widget In-Depth
PPTX
Hello, QML
PDF
Efficient Graphics with Qt
ODP
Cross Platform Qt
ODP
Intro to QML / Declarative UI
PDF
Qt for beginners part 2 widgets
 
Special Effects with Qt Graphics View
Qt for Beginners Part 3 - QML and Qt Quick
 
QThreads: Are You Using Them Wrong?
 
Convert Your Legacy OpenGL Code to Modern OpenGL with Qt
 
Qt on Real Time Operating Systems
Qt State Machine Framework
Copy Your Favourite Nokia App with Qt
Best Practices in Qt Quick/QML - Part 1 of 4
 
Necessitas - Qt on Android - from FSCONS 2011
Building the QML Run-time
Qt Workshop
Qt Widget In-Depth
Hello, QML
Efficient Graphics with Qt
Cross Platform Qt
Intro to QML / Declarative UI
Qt for beginners part 2 widgets
 
Ad

Viewers also liked (6)

PDF
Practical Model View Programming
ODP
Qt 5 - C++ and Widgets
PDF
Python Tricks That You Can't Live Without
PDF
Object-oriented Programming in Python
PDF
Python Advanced – Building on the foundation
PDF
Python Worst Practices
Practical Model View Programming
Qt 5 - C++ and Widgets
Python Tricks That You Can't Live Without
Object-oriented Programming in Python
Python Advanced – Building on the foundation
Python Worst Practices
Ad

Similar to Qt Graphics View Framework (Qt Developers Meetup Isreal) (20)

PPT
Developing and Benchmarking Qt applications on Hawkboard with Xgxperf
PDF
The Ring programming language version 1.6 book - Part 73 of 189
PDF
writing-custom-qtquickcomponents-QtCon.pdf
PDF
The Ring programming language version 1.2 book - Part 51 of 84
PPT
Qt Programming on TI Processors
PDF
Extended and embedding: containerd update & project use cases
PDF
Basics of gtk_ilugc
PDF
KDE 4.1 Plasma widgets
PPT
openGL basics for sample program (1).ppt
PPT
openGL basics for sample program.ppt
PDF
The Ring programming language version 1.8 book - Part 77 of 202
PPTX
JS digest. February 2017
PDF
Tools for developing Android Games
PDF
The Ring programming language version 1.7 book - Part 75 of 196
PDF
QT 프로그래밍 기초(basic of QT programming tutorial)
PPTX
Witekio custom modern qt quick components
PDF
Qt for beginners part 4 doing more
 
PDF
State of the Art OpenGL and Qt
 
PDF
Flink Forward Berlin 2017: Matt Zimmer - Custom, Complex Windows at Scale Usi...
PDF
Developing for Plone using ArchGenXML / ArgoUML
Developing and Benchmarking Qt applications on Hawkboard with Xgxperf
The Ring programming language version 1.6 book - Part 73 of 189
writing-custom-qtquickcomponents-QtCon.pdf
The Ring programming language version 1.2 book - Part 51 of 84
Qt Programming on TI Processors
Extended and embedding: containerd update & project use cases
Basics of gtk_ilugc
KDE 4.1 Plasma widgets
openGL basics for sample program (1).ppt
openGL basics for sample program.ppt
The Ring programming language version 1.8 book - Part 77 of 202
JS digest. February 2017
Tools for developing Android Games
The Ring programming language version 1.7 book - Part 75 of 196
QT 프로그래밍 기초(basic of QT programming tutorial)
Witekio custom modern qt quick components
Qt for beginners part 4 doing more
 
State of the Art OpenGL and Qt
 
Flink Forward Berlin 2017: Matt Zimmer - Custom, Complex Windows at Scale Usi...
Developing for Plone using ArchGenXML / ArgoUML

Recently uploaded (20)

PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Encapsulation theory and applications.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Approach and Philosophy of On baking technology
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
A Presentation on Artificial Intelligence
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
Machine Learning_overview_presentation.pptx
Chapter 3 Spatial Domain Image Processing.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Programs and apps: productivity, graphics, security and other tools
Encapsulation theory and applications.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
The Rise and Fall of 3GPP – Time for a Sabbatical?
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Network Security Unit 5.pdf for BCA BBA.
Diabetes mellitus diagnosis method based random forest with bat algorithm
Digital-Transformation-Roadmap-for-Companies.pptx
NewMind AI Weekly Chronicles - August'25-Week II
Approach and Philosophy of On baking technology
Reach Out and Touch Someone: Haptics and Empathic Computing
sap open course for s4hana steps from ECC to s4
Encapsulation_ Review paper, used for researhc scholars
Assigned Numbers - 2025 - Bluetooth® Document
Building Integrated photovoltaic BIPV_UPV.pdf
A Presentation on Artificial Intelligence
MIND Revenue Release Quarter 2 2025 Press Release
Machine Learning_overview_presentation.pptx

Qt Graphics View Framework (Qt Developers Meetup Isreal)

  • 1. vitali.pe@gmail.com vitali.p@volicon.com QT Graphics View Framework [vitali]: ~/qt-secene-demos/ >> python cool_intro.py Traceback (most recent call last): File "PySideexamplesopengloverpainting.py", line 198, in paintEvent self.resizeGL(self.width(), self.height()) File "PySideexamplesopengloverpainting.py", line 227, in resizeGL glViewport(((width - side) / 2), ((height - side) / 2), side, side) ctypes.ArgumentError: argument 1: <class 'TypeError'>: wrong type Traceback (most recent call last): File "PySideexamplesopengloverpainting.py", line 198, in paintEvent self.resizeGL(self.width(), self.height()) File "PySideexamplesopengloverpainting.py", line 227, in resizeGL glViewport(((width - side) / 2), ((height - side) / 2), side, side) ctypes.ArgumentError: argument 1: <class 'TypeError'>: wrong type
  • 2. Soo... QGraphicsScene.. Basically it’s a canvas library on (a lot of) steroids. Features: Model/View Architecture. It’s own event system (not signals & slots) Low level rendering (with QPainter) Input Handling (mouse & keyboard) Simple animation Support for embedding QWidgets Collision detection Drag & Drop ….
  • 4. Architecture Overview Only 3 Basic components item(s), that are added to the scene, and one or more views to display the scene. View View Graphics Scene Item Item VIew Item This is the actual QWidget, that is added to your layout... Item Item
  • 5. First, lets talk about rendering widgets in QT ● ● ● Widget render themselves by overriding paintEvent() QT uses the “painter's algorithm” Any Widget can be hardware accelerated. paintEvent() 1 paintEvent() 2 3 paintEvent() 4 paintEvent()
  • 6. Ok… so what about graphics scene? The graphics scene, has a different more flexible and optimized API for drawing and transforms , but the same principle apply…. 1 2 Also up until QT 5 , QML widgets where implemented on top of QGraphicsView 3 4
  • 7. Rendering in Qt 4.8 QML Via QGraphicsView Qt Webkit QWidget QPainter OpenGL Renderer Software Renderer
  • 8. Rendering in Qt 5 QML Qt Webkit QWidget QPainter SceneGraph OpenGL Renderer Software Renderer
  • 9. Why? you ask... Well… because painter’s algorithm will fuckup any OpenGL based rendering pipeline! QML Z-Buffering FTW! SceneGraph Yes you can get away with it on desktops when you're not developing AAA games… but Qt Quick is for moblie remember ? OpenGL Renderer
  • 10. The Item, View & Scene QGraphicsScene: ● ● ● ● itemAt(x : float, y : float) addItem(item : QGraphicsItem) addPixmap( pixmap : QPixmap) selectedItems() ... Providing an interface for managing items Propagating events to each item Managing item state, such as selection and focus handling Providing (untransformed) rendering functionality.
  • 11. The Item, View & Scene QGraphicsItem: ● ● ● ● ● ● setPos(pos : QPointF) setTransform(t : QTransform) setEnabled( enabled : bool) childItems() ... Mouse and keyboard input events Drag and drop Parent-child relationships. Collision detection. Has many many built-in sub types If you want to implement layers effects, etc… you need a custom item
  • 12. The Item, View & Scene QGraphicsView: ● ● ● ● ● mapFromScene(pos : QPointF) mapToScene(pos : QPointF) centerOn(pos : QPointF) setTransform(t : QTransform) ... Visualizes the contents of a scene. Is a subclass of QWidget A scene can have multiple views attached to it. Translates keyboard and mouse events to scene events Has it’s own transform matrix.