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

QGraphicsScene.itemAt() only returns zero and whole scene is slow

I am trying to create a dot matrix in a QGraphicsScene. I have a button, which fills a 2d-array with random numbers and than i will paint a pixel on every position where the array has a 0. Now, when I wants to generate the matrix again i want to…
honiahaka10
  • 772
  • 4
  • 9
  • 29
1
vote
0 answers

Qt - QGraphicsScene is overlapping images

So I was following this tutorial, https://deadbird.fr/?p=800, to obtain blur behind windows in qt.. Made some changes like request a capture() when a resize event is scheduled and added a timer to update every 200ms the image with QTimer so when for…
1
vote
0 answers

QGraphicsScene selection order

When the user selects QGraphicsItems, I want to be able to keep track of the order of how they are selected. Right now I'm using QGraphicsScene.selectedItems(), but it doesn't give me what was the last selected object. This seems clear after…
Green Cell
  • 4,677
  • 2
  • 18
  • 49
1
vote
1 answer

Removing multiple items from QGraphicsScene

In my Qt GUI, I have QGraphicsScene where QGraphicsItems are added. Now in order to delete the items, I'm using GraphicsScene::selectedItems() to return a list of items selected on the screen. This returns the memory address of selected items, their…
Vino
  • 167
  • 2
  • 14
1
vote
1 answer

How to filter visible QGraphicsItems from QGraphicsScene in QGraphicsView?

So, if I figure out this correctly, QGraphicsItem are (abstract) graphics items which belong to one QGraphicsScene (which is scene manager basically). QGraphicsView is specific "view" into that scene and multiple views can view same scene. If I were…
edin-m
  • 3,021
  • 3
  • 17
  • 27
1
vote
2 answers

Deleting a QGraphicsItem/QGraphicsObject from QGraphicsScene?

I have created Qt GUI application. It consists of QGraphicsScene, and items (QGraphicsItems) are added to them by pressing or triggering pushbuttons. Each item added to the scene are members of different classes derived from QGraphicsItem. Now, my…
Vino
  • 167
  • 2
  • 14
1
vote
1 answer

QGraphicsRectItem's signal itemChange not generating on drag

I have made a custom class derived from QGraphicsRectItem. class CornerPoint : public QGraphicsRectItem { public: CornerPoint(QPointF centre); enum { Type = UserType + 1 }; int type() const{ return Type; } QVariant…
Amit Tomar
  • 4,800
  • 6
  • 50
  • 83
1
vote
1 answer

qt - In QGraphicsScene how to catch a particular item

I have so many things in my QGraphicsScene. The situation is I am creating a chessboard, and is using Graphics scene. So the QGraphicsScene is having so many QGraphicsPixmapItems. Now In this how can I get the King. Update: In this…
prabhakaran
  • 5,126
  • 17
  • 71
  • 107
1
vote
1 answer

Qt: change QGraphicsItem receiver during mouse move

I am currently trying to implement a Bezier pen tool. The course of events looks like this: click on point (QGraphicsItem), start moving while clicked in QGraphicsScene mouseMoveEvent, prevent moves of point (with a boolean flag) until when…
blameless75
  • 2,148
  • 2
  • 19
  • 14
1
vote
1 answer

Cleaning up QList and QGraphicsScene to avoid memory leaks

I want to be thorough and clean up to avoid memory and object leaks. I had the misunderstanding that Qt cleans automatically objects that go out of scope, except pointers need to be deleted manually. In my code I have a number of QList...…
Thalia
  • 13,637
  • 22
  • 96
  • 190
1
vote
1 answer

Fill up a QGraphicsScene in a class and return the scene pointer

I'm implementing a class filling up a scene with my graphics item. I want to return a pointer to the scene from my class to main window. But for some reason when I try to do it, graphics view doesn't show anything. And the filling up function works…
Ivan
  • 16,536
  • 6
  • 23
  • 36
1
vote
1 answer

QGraphicsItem middle mouse press event

I'm using Qt 5.3 on Linux. I have a QGraphicsScene and a QGraphicsItem. In my QGraphicsItem I implemented mousePressEvent, mouseReleaseEvent, mouseMoveEvent, to catch mouse events. It works fine, but I have to double click (with middle button) to…
VargaD
  • 496
  • 1
  • 5
  • 9
1
vote
2 answers

graphicsview receives mouse event before the item

I have implemented the panning view on the QGraphicsView, using the mouse move event using void View::mouseMoveEvent(QMouseEvent* event) { pan(); QGraphicsView::mouseMoveEvent(event); } and in the scene of this view I have added few items where…
Wagmare
  • 1,354
  • 1
  • 24
  • 58
1
vote
1 answer

Printing QGraphicsScene Produces Low Quality Output

My code roughly resembles this: QGraphicsScene* pScene( pMap->scene() ); QPrinter printer; printer.setResolution( 1200 ); //tried many values and QPrinter::PrinterMode printer.setOutputFileName( "test.pdf" ); printer.setPageSize( QPrinter::A4…
William_Wilson
  • 1,244
  • 7
  • 16
1
vote
0 answers

remove all QGraphicsLineItem in QGraphicsScene.group from a QGraphicsScene

I'm trying to draw vector segments on top of a QGraphicsPixmapItem, i used the mouse events to draw a first "red-dash-line" to positioning the segment. When the mouse is released the segment vertex are stored in a list wich is then appended to an…
epifanio
  • 1,228
  • 1
  • 16
  • 26