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

Own objects into QGraphicsScene

I would like to have a drag-and-drop feature based on images. If I drag and drop an image I would like to know which image I picked out and moved with (a simple std::string will do to uniquely identify the object that that image is representing). My…
mmvie
  • 2,571
  • 7
  • 24
  • 39
2
votes
1 answer

Why are PNG images rendered from a QGraphicsScene being incorrectly offset?

I have a program that draws the contents of a QGraphicsScene to a PNG image. I have found that in some circumstances the PNG image is not being created correctly. The image generated appears to be 'offset' by some amount, in that the top-left…
Luke Woodward
  • 63,336
  • 16
  • 89
  • 104
2
votes
1 answer

Qt QGraphicsScene::drawItems subsitute?

For QGraphicsScene::drawItems the reference says: Reimplement this function to provide custom painting of all items for the scene; gaining complete control over how each item is drawn. But this function is marked as obsolete. Is there any new…
tonnot
  • 435
  • 1
  • 5
  • 17
2
votes
1 answer

Qt QGraphicsScene & OpenGL, which can be the best approach to mix both?

I'm going to start development on my vectorial viewer app. I have explored the 2D and 3D Qt tools and I have the impression that I have to create two independents data worlds. The QGrapchicsScene needs 'items', the OpenGL needs raw data. What is…
tonnot
  • 435
  • 1
  • 5
  • 17
2
votes
1 answer

Show QQuickWidget inside QGraphicsScene

I was upgrading some old code that was working fine to display my qml files inside a QGraphicsScene, but I was using the QDeclarativeView + QGraphicsProxyWidget method, so I converted to the new QT 6.5 / qtquick 2 format using QQuickWidget. OLD CODE…
2
votes
1 answer

PyQt5 QGraphicsView drawing resolution

I'm new to Qt, I am trying to make a paint application using QGraphicsScene and QGraphicsView. The only way to draw i found out is to add circles and lines to QGraphicsScene on mouseMoveEvent. It works fine, but is there a way to draw like in…
Rimuto
  • 33
  • 4
2
votes
1 answer

Set QGraphicsTextItem origin in PyQt

If I want to place one letter (a QGraphicsTextItem) in a QGraphicsView, is there any way I can set the text to display in the middle of the coordinates I specify? If I use QGraphicsTextItem.setPos(x,y), it treats the (x,y) as the top-left corner. I…
D K
  • 5,530
  • 7
  • 31
  • 45
2
votes
1 answer

Zooming in on mouse position with QGraphicsView Scene

I would like to enable the user to zoom in on an image in QGraphicView's Scene, allowing him to zoom in on the mouse position. I have tried to implent this zoom in several ways, yet unfortunately I haven't been able to get it work as needed. If…
2
votes
1 answer

How to add an image to QGraphicsScene so rectangle items can be located on it?

I have a python code that I can add multiple rectangles on a QGraphicsScene. from PyQt5 import QtCore, QtGui, QtWidgets class GraphicsScene(QtWidgets.QGraphicsScene): def __init__(self, parent=None): super(GraphicsScene,…
2
votes
1 answer

PyQt5: set coordinates for items in graphics scene

I have a scene = QGraphicsScene() and I added an ellipse via scene.addEllipse(100, 100, 10, 10, greenPen, greenBrush). The brush and the pen are set before. I add the QGraphicsScene right after to a QGraphicsView with MyGraphicsView.setScene(scene).…
Cpt. Crazy
  • 115
  • 1
  • 11
2
votes
3 answers

How to center text in QGraphicsSimpleTextItem?

Sorry for my English, it's not my native language. I have a problem - I need to center text in my QGraphicsSimpleTextItem. I inherited my class from QGraphicsSimpleTextItem. Do I need to override the paint() method or what should I do? I've read…
2
votes
1 answer

Not Rotating Image Correctly

I'm trying to rotate the background of my QGraphicsView object an I am getting in trouble. The red pen describes the problem what I'm getting. What I want: I want to keep the arrow centered in the middle of my screen. I want the background image to…
2
votes
1 answer

create a Qt display

I'm making an project that will use an arrow in a field as shown bellow. I want the object to move as it receives some data for movement - such as coordinates from a satellite. Questions are: How do I create the object arrow? What libraries should…
2
votes
1 answer

GraphicsView Scene postEvent focusProxy does not pass events from event filter to QWebEngineView Widget

I am currently learning how to write a GUI in PyQt5 that enable user to draw lines and rectangles in a QGrapchisView Scene and sets a QWebEngineView Widget containing a folium map as background. Issue: In order to synchronize QGrapchisView Scene…
MBV
  • 591
  • 3
  • 17
2
votes
2 answers

QGraphicsView - slow scale performance under Linux

I'm making a program that will display a few images from a directory beside each other. When I scale the images to fit within the height of the window (ie - QGraphicsPixmapItem->scale(...)), it runs fairly well in windows, but runs unbearably slow…
jdrea
  • 53
  • 4