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
1 answer

How to paint sequential image in efficient way in QQuickPaintedItem

For some reason, I needs to wrap opencv VideoCapture in a class which will be used in Qt Quick. There are two classes, one is Camera, other is CameraView. CameraView inheritd from QQuickPaintedItem. Camera class will get image periodically. It…
A.J
  • 338
  • 1
  • 4
  • 16
4
votes
1 answer

Qt5 scribble with layers - QPaintDevice: cannot destroy device that is being painted

I'm trying to re-implement the scribble demo app for multiple layers of images. I am struggling to draw into the pixmap within the scene as the Painter complains that is being destroyed to early. QPaintDevice: Cannot destroy paint device that is…
jonathanbsyd
  • 8,031
  • 6
  • 24
  • 26
4
votes
4 answers

Crash after QGraphicsScene::removeItem() with custom item class

I am populating a QGraphicsScene with instances of a custom item class (inherting QGraphicsPathItem). At some point during runtime, I try to remove an item (plus its children) from the scene by calling: delete pItem; This automatically calls…
Philip Allgaier
  • 3,505
  • 2
  • 26
  • 53
4
votes
1 answer

I need to print a QGraphicsScene to actual (inch/mm) scale

I am trying to print the contents of a QGraphicsScene. The target printer could be anything - from the normal printers to custom size special printers. It must print things at actual size (inches, mm....). In the QGraphicsScene I am using the…
Thalia
  • 13,637
  • 22
  • 96
  • 190
4
votes
1 answer

QGraphicsScene::addItem: item has already been added to this scene

I tried to add several items to QGraphicsScene, but after calling scene->addItem(new Bonus(Bonus::BonusType::coin, randPoint, pixels, parent)); in application output appears this message: QGraphicsScene::addItem: item has already been added to this…
medegor44
  • 107
  • 1
  • 6
4
votes
1 answer

How to enable dragging in QGraphicsScene?

I'm trying to put two pictures in the QGraphicsScene. One is fixed and the other one is movable. But I succeed only in putting those pictures in the QGraphicsScene, I can't move them. How can I achieve this?
prabhakaran
  • 5,126
  • 17
  • 71
  • 107
4
votes
1 answer

Rendering a QGraphicsScene with QGraphicsVideoItem to QImage

This part is solved I want to render a QGraphicsScene with QGraphicsVideoItem to QImage. Everything works when the QGraphicsScene is just with a QGraphicsTextItem. However, if I replace QGraphicsTextItem with a QGraphicsVideoItem, it fails to get a…
4
votes
1 answer

QGraphicsScene::clear() and destructor performance

I am using a QGraphicsScene to display a very large number of items, often more than 100,000. When I call delete the scene, it takes an unusually long time to complete, 10 seconds or more. A bit of experimenting revealed that the…
rrwick
  • 619
  • 7
  • 19
4
votes
1 answer

Graphics errors with QWidgets in a QGraphicsScene

I am trying to have a widget live freely inside a large scrollable panel. When I scroll around the QGraphics view, the child widget does not draw properly— its sub-rectangles will blank out, and the borders (which are rounded) are not blended with…
trbabb
  • 1,894
  • 18
  • 35
4
votes
1 answer

Drawing line in QGraphicsScene with Qt

I have a problem with drawing lines. It works well when the mouse moves slowly, but when the mouse is moved faster, there are some gaps and I don't have any idea why. This is the…
Bartek El
  • 43
  • 1
  • 3
4
votes
1 answer

Items in a QGraphicsScene near the mouse

I am trying to find the items under the mouse in a scene. The code I am using is as follows: QPainterPath mousePath; mousePath.addEllipse(mouseEvent -> pos(),5,5); QList itemsCandidate = this->items(mousePath); if…
Francesco
  • 481
  • 2
  • 4
  • 16
4
votes
1 answer

How to get the exact location from a click on the qgraphicsscene in Qt

I am writing codes to load in image from a file and did some edits on this image(change some pixels' value), zoomed in or zoomed out and then save the image. Also, I want to know the location in the original image associated to a click on the…
ivory
  • 243
  • 4
  • 16
4
votes
3 answers

How to move around 1000 items in a QGraphicsScene without blocking the UI

I have around 1000 graphics item in my QGraphicsScene. I want to move all of these 1000 items to new position. New positions don't relate to each other and all of them should be done at the same time. One way is to iterate through these 1000 items…
s4eed
  • 7,173
  • 9
  • 67
  • 104
4
votes
1 answer

Drag and drop of QGraphicsItem between two pairs of QGraphicsScene/QGraphicsView

I have an application with a mainwindow in which I create a QGraphicsScene like this: DiagramWindow::DiagramWindow() { scene = new QGraphicsScene(0, 0, 600, 500); Then on the same program, I'm calling another window with another…
Joum
  • 3,189
  • 3
  • 33
  • 64
4
votes
1 answer

itemAt not returning custom qGraphicsItem

I have a custom implementation of qGraphicsScene and a custom qGraphicsItem that I click on, but the itemAt function never returns a value, even though I am fairly certain that I'm clicking on the item. void…
c0nn
  • 317
  • 3
  • 18