vitali.pe@gmail.com
vitali.p@volicon.com

QT Graphics View Framework
[vitali]: ~/qt-secene-demos/ >> python cool_intro.py
...
Soo... QGraphicsScene..
Basically it’s a canvas library on (a lot of) steroids.

Features:
Model/View Architecture.
It’s o...
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
s...
First, lets talk about rendering widgets in QT

●
●
●

Widget render themselves by overriding paintEvent()
QT uses the “pa...
Ok… so what about graphics scene?
The graphics scene, has a different more flexible
and optimized API for drawing and tran...
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!
...
The Item, View & Scene

QGraphicsScene:
●
●
●
●

itemAt(x : float, y : float)
addItem(item : QGraphicsItem)
addPixmap( pix...
The Item, View & Scene

QGraphicsItem:
●
●
●
●
●
●

setPos(pos : QPointF)
setTransform(t : QTransform)
setEnabled( enabled...
The Item, View & Scene

QGraphicsView:
●
●
●
●
●

mapFromScene(pos : QPointF)
mapToScene(pos : QPointF)
centerOn(pos : QPo...
Questions ?
Upcoming SlideShare
Loading in...5
×

Qt Graphics View Framework (Qt Developers Meetup Isreal)

835

Published on

http://www.meetup.com/QtEverywhere/Tel-Aviv-Yafo-IL/1077772/

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
835
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
24
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Qt Graphics View Framework (Qt Developers Meetup Isreal)

  1. 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. 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 ….
  3. 3. Demo App https://bitbucket.org/vitalipe/sggle/wiki/Home
  4. 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. 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. 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. 7. Rendering in Qt 4.8 QML Via QGraphicsView Qt Webkit QWidget QPainter OpenGL Renderer Software Renderer
  8. 8. Rendering in Qt 5 QML Qt Webkit QWidget QPainter SceneGraph OpenGL Renderer Software Renderer
  9. 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. 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. 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. 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.
  13. 13. Questions ?
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×