Questions tagged [qgraphicsscene]

A QGraphicsScene is a class from the Qt toolkit that provides a surface for managing a large number of 2D graphical items.

The QGraphicsScene class is part of Qt's Graphics View Framework and serves as a container for QGraphicsItems. It is used together with QGraphicsView for visualizing graphical items, such as lines, rectangles, text, or even custom items, on a 2D surface.

A QGraphicsScene also provides functionality which can efficiently determine both the location of items, and which items are visible within an arbitrary area on the scene. It has no visual appearance of its own; it only manages the items. A QGraphicsView widget is needed to visualize the scene.

The official Qt documentation can be found here.

874 questions
1
vote
1 answer

How can I layer images in PyQt using QGraphicsScene and QGraphicsView

Let's say I have two images, image A and image B. Using QGraphicsScene and QGraphicsView, how can I draw image A to the background, and layer image B on top of image A? Thanks in advance.
Calvin
  • 11
  • 2
1
vote
1 answer

How to change the color of a QGraphicsRectItem

I can't find where I'm doing wrong. I want to change the color of my item (a QGraphicsRectItem) when a particular event occurs. The fact is that it seems that once the override paint method is called, the color won't change no matter what. This is a…
Branda
  • 73
  • 8
1
vote
1 answer

Join QGraphicsItem and QPainter in same GraphicsScene

I am currently building an interactive canvas using PyQt5 and Graphicscene, so far modifying the codes found on those posts: PySide Node Graph connect items How to draw a line from mouse to a point in PyQt5? I have made two separates examples of…
MBV
  • 591
  • 3
  • 17
1
vote
1 answer

custom QGraphicsItem not moving properly

I tried to customize QGraphicsItem to make a pawn item that will be movable but will be centered on a case when dropped (modeling a checkers or chess board) i encountered a problem at the very start as my custom graphic item does not move properly,…
nzz coding
  • 47
  • 7
1
vote
0 answers

How to snap objects to a grid in the QGraphicsScene?

This code implements the ability to move objects with the mouse by using the QGraphicsItem.ItemIsMovable flag. But how to make objects move with a snap to a grid? from PyQt5 import QtGui from PyQt5.QtWidgets import QApplication, QMainWindow,…
fromgate
  • 21
  • 3
1
vote
1 answer

pyqt5 drawing lines with a button on a QGraphicsScene

I've a problem with pyqt5. I've create a windows with a scene that has a background image, re-implementing drawBackground. I've also a button that allow me to add a line in a position on the scene. The problem is that if i click the button to draw…
Luca Faraoni
  • 175
  • 1
  • 7
1
vote
1 answer

QGraphicsScene::clear() method crashes only in release mode

I inherited my scene from QGraphicsScene. I add many items(QGraphicslineItem, QGraphicsItem, QGraphicsTextItem) on this scene. Whenever i try QGraphicsSceneClear method it crashes on release mode. It works fine on debug mode. Note: Some items have…
ozdemir
  • 23
  • 4
1
vote
1 answer

QGraphicsView not repainting on scroll event

QT 4.7 I have a QGraphicsView / QGraphicsScene. The scene has a custom QGraphicsItem the whole scene is not displayed at one time, so it has a viewport. I'm overriding the paint() method of my QGraphicsItem as follows: void paint(QPainter *painter, …
LeviX
  • 3,096
  • 3
  • 28
  • 41
1
vote
1 answer

Detect Drag on Drop over all Child QWidgets

I'm trying to implement Drag and Drop behavior, across my whole application, I would like to execute some action when a drop occurs, no mater where in the MainWindow. The Problem that I'm facing is that in my MainWindow, I have a Widget which…
Damir Porobic
  • 681
  • 1
  • 8
  • 21
1
vote
1 answer

Extending QGraphicsScene

I am extending QGraphicsItem to be added to a extended QGraphicsSene. when I added the extended item to the scene and the scene to the graphics view in the normal way it shows the image but when I added the image as follows it does not show. could…
Tharanga
  • 2,007
  • 4
  • 32
  • 50
1
vote
1 answer

How to set (0,0) to the top left corner of QGraphicsScene

Is it possible to set (0,0) to the top-left corner of the QGraphicsScene? It seems to be at the center of the view by default: class GraphicsScene : public QGraphicsScene { protected: void mouseMoveEvent(QGraphicsSceneMouseEvent *event)…
Thinium
  • 171
  • 1
  • 14
1
vote
1 answer

How can I subclass QGraphicsRectItem and QGraphicsEllipseItem in one class?

I'm using Pyside2 and have a UI that uses QGraphicsView and a QGraphicsScene. Right now I have two separate classes that subclass QGraphicsEllipseItem and QGraphicsRectItem like this: class MyRectButton(QGraphicsRectItem): def…
1
vote
1 answer

Where should I be catching touch events for painting on a QGraphicsScene?

I want to reimplement the Qt fingerpaint example using my QGraphicsScene rather than a QWidget. However I cannot find an example of this so am unsure if I should capture the events at the view and pass them down to the scene or something else. …
Phil Hannent
  • 12,047
  • 17
  • 71
  • 118
1
vote
2 answers

sceneRect().translated(x,y) doesn't work properly with zoom

A month ago I was asking, how to make scene translated and I got great help and understood how make it work, and after a month working with it/adding staff I noticed that when you zoom in quite close to geometry or somewhere else, translation…
Vlad
  • 387
  • 3
  • 17
1
vote
1 answer

Zooming into cursor in GraphicsView/GraphicsScene

I have a QGraphicsView widget which I'm using as a drawing canvas. I want to be able to zoom into the mouse cursor position on ctrl+mwheel. As my code stands, it is scrolling only it seems into the center of the canvas, and not into the cursor…
Connor Spangler
  • 805
  • 2
  • 12
  • 29