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

QGraphicsScene: Artifacts when rendering and saving the scene to a file

I am working with PyQt5 (Version 5.15.7) in PyCharm Community on Windows 11. I have subclassed the QGraphicsScene and added some attribute and methods I need. I add some QGraphicsItems and QGraphicsItemGroups on the scene and display it in a…
1
vote
1 answer

Can't zoom in after implementing fitInView() in Qt

I'm working on a project in Qt and the thing I've to do is to have an image in the background(can be png or jpg). I've created a view with a scene with QGraphicsView and QGraphicsScene. QGraphicsPixmapItem * image = new…
Prakhar
  • 49
  • 7
1
vote
1 answer

QGraphicsScene::itemAt() not working properly

I am trying to find out the QGraphicsItem under the mouse (when mouse hover over the item). For that I am using itemAt() method but itemAt() is not returning QGraphicsItem. I tried this way: bool myViewer::eventFilter(QObject *watched, QEvent…
tushar
  • 313
  • 4
  • 10
1
vote
0 answers

How to undo-redo features like zoom in, zoom out using Command pattern in Qt?

I have a QGraphicsView, which contains rectangle, polyline, text etc. I also have some features to transform the view like zoom in, zoom out, Fit in view, change the color on mouse right click etc. I want to add few more features like Undo and…
tushar
  • 313
  • 4
  • 10
1
vote
1 answer

Qt Application with layout's, QPushButton and QGraphicsItem

I am trying to draw various shapes like rectangle, ellipse, text etc uisng QGraphicsView and QGraphicsScene. For that I am trying to create an interface where there will be a vertical layout and besides that there will be few buttons. On clicking…
tushar
  • 313
  • 4
  • 10
1
vote
0 answers

Error : Non-static member found in multiple base-class subobjects of type QGraphicsItem

I am trying to achieve rubber band rectangle zoom in. But here I need to zoom in only the part which comes under rubber band rectangle. I do not want to zoom in the whole view. For that I was told to create rubber band rectangle whose point I will…
tushar
  • 313
  • 4
  • 10
1
vote
1 answer

How to change background color in QGraphicsScene?

I want to give background color in my QGraphicsScene. For that, I have override drawBackground() method, and tried to set color but it is not working. Background color is not changing. Here is my drawBackground()…
tushar
  • 313
  • 4
  • 10
1
vote
1 answer

How to disable Qt (5) high-dpi scaling temporarily?

I know that I can disable DPI scaling for the entire application by calling QApplication::setAttribute( Qt::AA_DisableHighDpiScaling ); before creating the QApplication instance. But, is it possible to set a QPainter/QGraphicsScene/QGraphicsView to…
user41010
  • 91
  • 8
1
vote
1 answer

Select items with RubberBandDrag only when it's released

I have a QGraphicsScene where I have QGraphicsItems and enabled rubberBand selection. I want to select these items with rubberband selection but I want them to become selected only when the rubber band is released. Now it selects/deselects items…
galaxy
  • 53
  • 1
  • 1
  • 15
1
vote
2 answers

Animate QGraphicsView fitInView method

So lets say I have a simple QGraphicsView and QGraphicsScene, and I want to animate the view to smoothly scroll/scale over to an arbitrary QRecF within the scene. I know you can call view.fitInView() or view.centerOn() to 'frame up' on the rect,…
Spencer
  • 1,931
  • 1
  • 21
  • 44
1
vote
1 answer

Extend graphics item movement around other items without overlap

I have a graphics scene with QGraphicsEllipseitem circles that are movable. I am trying to prevent the circles from overlapping by having the one that am dragging to move around the other circles that it collides into. So far it works for 1…
drivereye
  • 33
  • 5
1
vote
1 answer

Update QGraphicsScene from another, non-main thread

I'm pretty new to QT's graphic view frame, and I couldn't find anything about this in the docs or on Google. I have a GUI application that draws a representation for some data. The application itself does some work with matrices / vectors (a neural…
TC1
  • 1
  • 3
  • 20
  • 31
1
vote
1 answer

Make graphics item move around another item instead of passing through

I have a graphics scene with QGraphicsEllipseitem circles that are movable. I am trying to have the one I am dragging move around the other circle instead of allowing them to overlap aka collide. So far I was able to stop the collision but its not…
drivereye
  • 33
  • 5
1
vote
1 answer

Drag and Drop QTreeWidgetItem to QGraphicsView with custom data

I've a class containing a QTreeWidget, where I have some QTreeWidgetItem. I want to drag and drop a QTreeWidgetItem into a QGraphicsScene, in order to create an object in there. The object is a rectangle with the text of the QTreeWidgetItem in…
Jepessen
  • 11,744
  • 14
  • 82
  • 149
1
vote
1 answer

How to create a GUI with multiple lines of glyphs/text in parallel where the glyphs have x and y coordinates

I'm currently creating an application to edit parallel lists of events which happen on a timeframe. In the model/backend there is a list of lists where the sublist has all the items in order. Each event should be represented by a string/glyph (from…
nilshi
  • 504
  • 1
  • 6
  • 16