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

QGraphicsView rubber band selection rectangle not visible

I have a QGraphicsView widget with lots of items on scene. I am panning the view on ctr+left mouse click and zooming it to rectangle of rubber band created with left mouse button drag. I am not able to see rubber band selection rectangle (dotted…
TRS
  • 1,947
  • 4
  • 26
  • 49
4
votes
1 answer

Remove single items/QLineF's from QGraphicsScene

I have drawn a grid into a qgraphicsscene with QLineF's and you can add custom qgraphicsitems into the scene as blocks in the grid. I want to be able to redraw the grid with different spacing and indexing (indexes are just thicker lines). My problem…
deprecated
  • 57
  • 1
  • 7
4
votes
3 answers

QGraphicsScene::clear() clearing scene but not the view

I use a custom class (Configuration) derived from QGraphicsItem and I add its objects to a QGraphicsScene, which is then displayed in a QGraphicsView. Usual stuff. What Im doing exactly is drawing a tree, in multiple steps, one level a step, each…
TeaOverflow
  • 2,468
  • 3
  • 28
  • 40
4
votes
2 answers

Need QGraphicsScene signal or event for _after_ change

I use QGraphicsScene of the Qt framework. Inside the scene I have some QGraphicsItems which the user can select and move. I would like to have an info label where the current x and y coordinate of the currently moved selection (can consist of many…
eikuh
  • 673
  • 1
  • 9
  • 18
4
votes
1 answer

Rotate QGraphicsPixmapItem with mouse

I'm writing an application in PyQt that will allow users to select images placed on a QGraphicsScene (using a custom QGraphicsPixmapItem). Upon selection I would like a rotation handle to appear on the image that the user can "grab" with the mouse…
jsaugustyn
  • 53
  • 1
  • 5
4
votes
2 answers

Subclassing QGraphicsView and setting drawBackground

I'm trying to make a function similar to impoly (from matlab) in Qt. Right now, I have a subclass of QGraphicsView and have set the virtual function "drawBackground" as: void roiwindow::drawBackground(QPainter *painter, const QRectF…
JustinBlaber
  • 4,629
  • 2
  • 36
  • 57
3
votes
1 answer

QGraphicsTextItem RightToLeft text

I have to write some Farsi texts to a QGraphicsTextItem , but I can't find how I can make QGraphicsTextItem to write RightToLeft!. Can any one help me?. I tryed this way but it didn't work for me: class DiagramTextItem(QtGui.QGraphicsTextItem): def…
3
votes
1 answer

QGraphicsView::setSceneRect() scrolls the viewport instead of panning

I'm attempting to create a pannable QGraphicsScene in a resizeable QGraphicsView. When resizing, I need to keep the scene size fixed and instead use a transform on the view to ensure the scene always "covers" the viewport. The result is a nicely…
mrg95
  • 2,371
  • 11
  • 46
  • 89
3
votes
2 answers

PyQt5: Filling in the holes in QPolygon // Increasing the size (height) of a qpolygon

I have the following QPolygon: and I need to increase its size in height to get a following QPolygon: whereas the lower boundary of the qpolygon stays in the same location, that is x1,y1 in the first image, is still x1,y1 in the second image and…
John_Doe
  • 95
  • 1
  • 11
3
votes
2 answers

Qt: QGraphicsScene not updating when I would expect it to

Ok so I've got a QGraphicsScene in a class called eye. I call a function: void eye::playSequence(int sequenceNum) { for (int i=0; i
JCL
  • 189
  • 1
  • 2
  • 11
3
votes
1 answer

Qt add item in the center of the scene/ view

Greetings, I'm trying to add a QGraphicsItem exactly in the center of the current screen. My QGraphicsScene is very large (10k X 10K), so the QGraphicsView cannot show it entirely, there are scroll bars. I can't find any function to return me the…
Cristi Constantin
  • 554
  • 1
  • 6
  • 19
3
votes
1 answer

How to remove QRect from QGraphicsScene

I have a QGraphicsScene with a bunch of QRects. I'm using the QRects as an overlay over a QPixmap to show detected object. I need to clear all the rectangles from the scene, but can't figure out how. What is the best way to clear all of the QRects…
noel
  • 2,257
  • 3
  • 24
  • 39
3
votes
1 answer

How to center widgets on scene QGraphicsScene

I want to align the scene in the middle. My problem is that when you open an application, widgets are aligned somehow below the middle, but after hovering over buttons or a label, the widgets are aligned in the middle. Can I fix this somehow? Is…
3
votes
1 answer

How to resize QWidget added in QGraphicScene through QGraphicsProxy?

I have added a widget to a graphic scene (QGraphicScene) through a QGraphicsProxyWidget. To move and select the widget added QGraphicsRectItem handle. To resize widget added QSizegrip to widget. But when i resize widget more than the QGraphicsRect…
Sagar A W
  • 338
  • 1
  • 12
3
votes
1 answer

Use a QGraphicsSceneMouseEvent in a class that inherits from QGraphicsView

I have a class that inherits from QGraphicsView. I use a QGraphicsScene to display an image in a window. Here it works properly. However, I would like to use the QGraphicsSceneMouseEvent mouse events to draw on this image. The problem is that if I…
user8632386