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 to retrieve QGraphicsRectItem coordinate with respect to a QGraphicsPixmapItem on a scene?

What is the best way to retrieve the QGraphicsRectItem coordinates with respect to the QGraphicsPixmapItem on the scene? Here is the code for my main window class. import sys from PySide2 import QtCore, QtGui from PySide2.QtWidgets import * from…
jon_bovi
  • 71
  • 3
  • 11
1
vote
1 answer

How to add image to QGraphicsView

I am going to put an image on a QGraphicsView. But I am having some difficulty in adding dynamically. I load QGraphicsView itself from test.ui. The window has a button (id open) and QGraphicsView itself (id gv). The program crashes on…
Alex
  • 41
  • 1
  • 8
1
vote
1 answer

How to add item in a QGraphicsScene?

I am trying to add some custom QGraphicsItems in a QGraphicsScene on mouse click and at mouse cursor coordinates. But the items are not added at the same coordinates as the mouse cursor's. renderArea::renderArea(QWidget *parent): …
schmimona
  • 849
  • 3
  • 20
  • 40
1
vote
1 answer

Moving items in QGraphicsView

I am new to Qt in general and QGraphicsView in particular. When I rotate a Qgraphicspixmapitem in it, it appears to move also. I have figured out that this has something to do with the QGraphicsView adjusting to keep the scene in view. I have…
MaXes
  • 11
  • 2
1
vote
1 answer

Error by creating a list of QGraphicsItems

I have a QGraphicsScene on which I would like to draw some special curves. For that I made a class in which I define these special curves as a new QGraphicsItem: #include < QGraphicsItem> class Clothoid : public QGraphicsItem { …
schmimona
  • 849
  • 3
  • 20
  • 40
1
vote
1 answer

QGraphicsScene and QGraphicsItem handlers

I'm new to Qt, and specially to PyQt5. I'm trying to develop a GUI using QGraphicsView, QGraphicsScene and QGraphicsPixmapItem. My objective is to add items to the scene when the user clicks on the scene (achieved using mousePressedEvent() in a…
dpoloa
  • 15
  • 3
1
vote
0 answers

QGraphics paints custom widget differently in paintEvent than resizeEvent and vice-versa

I have written code for my graph and it works fine, but when I need to resize it, problems start. Resize event doesn't fit my QGraphicScene to QGraphicsView, but same code in paint event works fine. I can't use paint event, 'cause it makes recursive…
Rokker
  • 73
  • 6
1
vote
1 answer

Embedding a QOpenGLWidget via addWidget in QGraphicsScene

Some time ago I created a subclass of QGraphicsView that I called MultiWidget. Its purpose was to hold some other widgets I use, which I added with addWidget to the QGraphicsScene associated to my MultiWidget. The idea was, that MultiWidget should…
Jürgen Böhm
  • 389
  • 3
  • 11
1
vote
1 answer

Correct way to draw a QGraphicsItem on QGraphicsScene

I checked a couple of resources on qt's website and here but I could not solve my problem. I'm trying to draw a rectangle on QGraphicsScene on mouse click and I want the new rectangle to be centered exactly where the user clicked but this does not…
1
vote
1 answer

How can I draw a transparent line continues inside the QGraphicsview without overlap?

I'm trying to draw a path made up of lines in two ways: the first, the path is made of straight lines, which have their extremities in common. The problem with using this methodology is that the lines overlap in their extremities causing an…
1
vote
1 answer

Selection exclusion in nested QGraphicsScenes

I have a QGraphicsScene (let's call it mother scene) that includes items, and some of them include a QGraphicsScene as well (let's call them daughter scenes). Observation : The selection in the daughter scene and in the mother scene don't bother…
Gustavitch
  • 23
  • 3
1
vote
2 answers

PyQT5 setRect moves origin point in a QGraphicsScene

Whenever i try to move a rectangle in a scene, the origin point of the rectangle appears to change to the location where the rectangle was before updating the location. So if i create the rectangle at (0,0) and move it using rect.setRect(x, y) then…
1
vote
1 answer

PyQt5: All Items of GraphicsScene have coordinates 0.0

I used the following source and modified it a bit, to get the following mini example: import sys from PyQt5 import QtCore, QtWidgets class GraphicsScene(QtWidgets.QGraphicsScene): def __init__(self): super(GraphicsScene,…
Deep-Learner
  • 109
  • 1
  • 3
  • 14
1
vote
1 answer

How to make QSvgGenerator produce vectorized SVG instead of bitmapped SVG?

I'm trying to export my QGraphicsScene to an SVG like this: void MyScene::toSvg(QString filename) { QSvgGenerator svgGen {}; svgGen.setFileName(filename); svgGen.setSize({ 200, 200 }); svgGen.setViewBox(QRect(0, 0, 200, 200)); …
juzzlin
  • 45,029
  • 5
  • 38
  • 50
1
vote
1 answer

get mouse position in the QGraphicScene with pixels coordinate

i try to create a program to manipulate images,I want to have the position of the mouse when it is in the Qgraphicscene, but the event of the mouse is not triggered unless I start outside the Qgraphicview, how can i get this position with the…
Ay Men
  • 90
  • 7