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
2
votes
0 answers

How to smootly update QGraphicsScene inside QGraphicsView after adding an item?

I'm running some tests in order to undestand what is the best way to update the GUI of a QDialog in a separate thread. I did the following: main.cpp (untouched) #include "dialog.h" #include int main(int argc, char *argv[]) { …
Michael
  • 876
  • 9
  • 29
2
votes
2 answers

QGraphicsPathItem hoverEvents - suppress hover on area formed by the path

https://www.dropbox.com/s/phven3rriv36893/graphicsview-pathitem.png?dl=0 I wonder if there's a way to make my QGraphicsPathItem respond to mouseHoverEvents to the actual curve instead of the whole orange area as seen in the…
2
votes
2 answers

Qt How to connect two QGraphicsItem by drawing line when items are movable

I have two QGraphicsItem in a scene and I want to draw a line between this two objects. However, these objects are movable and I don't know how to update a line after every movement ?
Makumba
  • 85
  • 3
  • 8
2
votes
1 answer

QGraphicsScene & OpenGL Fragment Shader Not Working

I have a very large QGraphicsScene that can contain a very large number of graphics. I'm using a QGLWidget as the viewport so that I can leverage OpenGL to try to improve how some things get rendered. I have created a custom QGraphicsItem that I…
Moohasha
  • 245
  • 1
  • 13
2
votes
1 answer

How can I show/hide background drawing on QGraphicsScene or QGraphicsView?

I would like to have certain things drawn on QGraphicsScene, but not be QGraphicsItem (it would interfere with the processing of the QGraphicsItem collection). Example: a scene bounding rectangle, a grid I am overriding the drawBackground(QPainter…
Thalia
  • 13,637
  • 22
  • 96
  • 190
2
votes
1 answer

How can I skip QGraphicsItems obscured by identical QGraphicsItems?

I am adding items on a QGraphicsScene. Once added, items may be further processed. I would like to skip the items completely obscured by other items. It seems that there are several QGraphicsItems dedicated to this task. Given two QGraphicsItem…
Thalia
  • 13,637
  • 22
  • 96
  • 190
2
votes
1 answer

QGraphicsScene rendering only certain children

I implemented layers in my painting application. Each layer has a thumbnail preview. I want the thumbnail of a layer to only show the items that belong to that layer. Right now I call scene->render() that renders all items to the thumbnail. How can…
user2366975
  • 4,350
  • 9
  • 47
  • 87
2
votes
2 answers

How to use local coordinates to a QGraphicsItem

I created a custom qGraphicsRectItem which I added to my qGraphicsScene. I would like to add text to this custom rectangle using its local coordinates (i.e. adding to 0,0 places the item at the origin of my rectangle no matter where it its in my…
user1337
  • 69
  • 1
  • 7
2
votes
0 answers

PyQt: Moving multiple items with different ItemIgnoresTransformations flags

Sometimes selected items do not move together. This happens in an application with two types of items: "regular items" "handles" with ItemIgnoresTransformations flag (they must keep the same size upon zooming) When they are selected together, and…
ederag
  • 2,409
  • 25
  • 49
2
votes
1 answer

QT Display a QWidget above QGraphicsScene

Currently I have a QGraphicsScene that is put inside a QGraphicsView and is shown on the display. I add all my elements to my scene that I set as the active scene. int main(int argc, char *argv[]) { QApplication a(argc, argv); QGraphicsView…
jdepypere
  • 3,453
  • 6
  • 54
  • 84
2
votes
2 answers

Arc in QGraphicsScene

I want to implement arc in QGraphicsScene. I want that on clicking of three points my arc should be drawn such that on clicking of three points arc is drawn where first point will be starting of arc, second will be any point on arc and third will be…
user3859872
  • 777
  • 2
  • 9
  • 16
2
votes
1 answer

Qt subclassed graphics scene does not allow me select/focus to graphics item on it

I have subclassed my own qgraphicsview because i wanted to send signals from scene with positions when clicked, on this scene are also my sublclassed graphics itms which are selectable and focusable. The problem is, when i implement my own…
mishan
  • 1,177
  • 3
  • 19
  • 42
2
votes
2 answers

Is there a possibility to get top-level items in a Qt QGraphicsScene?

I am using the QGraphicsScene in Qt5 to add different QGraphicsItems. Some of them have further child items, some not. But now I need the possibility to find all top-level items. Surely, I could write a method, which would use the…
quarenjo
  • 47
  • 7
2
votes
1 answer

Draw a scale ruler in QGraphicsScene?

I am building a map widget (something like the google map) using Qt, basically I used a QGraphicsScene to display the map tile. Now I want to add a scale ruler to the widget just like the one in google map. Any suggestions about how could I realize…
Nyaruko
  • 4,329
  • 9
  • 54
  • 105
2
votes
2 answers

Qt: Custom QGraphicsItem not showing when boundingRect() center is out of view

I'm making a Diagram (Fluxogram) program and for days I'm stuck with this issue: I have a custom QGraphicsScene that expands horizontally whenever I place an item to it's rightmost area. The problem is that my custom arrows (they inherit…
Qvaliz
  • 23
  • 4