Qt Graphics View Framework (Qt Developers Meetup Isreal)
Upcoming SlideShare
Loading in...5
×
 

Qt Graphics View Framework (Qt Developers Meetup Isreal)

on

  • 552 views

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

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

Statistics

Views

Total Views
552
Views on SlideShare
552
Embed Views
0

Actions

Likes
0
Downloads
3
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

CC Attribution License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Qt Graphics View Framework (Qt Developers Meetup Isreal) Qt Graphics View Framework (Qt Developers Meetup Isreal) Presentation Transcript

    • 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 ?