widgets.custom_qgraphicsscene

Custom QGraphicsScene used in the Design View.

author:
  1. Savolainen (VTT)
date:

13.2.2019

Module Contents

class widgets.custom_qgraphicsscene.CustomQGraphicsScene(parent, toolbox)[source]

Bases: PySide2.QtWidgets.QGraphicsScene

A scene that handles drag and drop events of DraggableWidget sources.

files_dropped_on_dc[source]
connect_signals(self)[source]

Connect scene signals.

resize_scene(self)[source]

Resize scene to be at least the size of items bounding rectangle. Does not let the scene shrink.

scene_changed(self, rects)[source]

Resize scene as it changes.

handle_selection_changed(self)[source]

Synchronize selection with the project tree.

set_bg_color(self, color)[source]

Change background color when this is changed in Settings.

Parameters:color (QColor) – Background color
set_bg_grid(self, bg)[source]

Enable or disable background grid.

Parameters:bg (boolean) – True to draw grid, False to fill background with a solid color
dragLeaveEvent(self, event)[source]

Accept event.

dragEnterEvent(self, event)[source]

Accept event. Then call the super class method only if drag source is not a DraggableWidget (from Add Item toolbar).

dragMoveEvent(self, event)[source]

Accept event. Then call the super class method only if drag source is not a DraggableWidget (from Add Item toolbar).

dropEvent(self, event)[source]

Only accept drops when the source is an instance of DraggableWidget (from Add Item toolbar). Capture text from event’s mimedata and show the appropriate ‘Add Item form.’

drawBackground(self, painter, rect)[source]

Reimplemented method to make a custom background.

Parameters:
  • painter (QPainter) – Painter that is used to paint background
  • rect (QRectF) – The exposed (viewport) rectangle in scene coordinates