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

Qt check if mouse in bounding rect of QGraphicsItem

I want to drag GQraphicsPixmapItem by clicking on any point inside bounding rect of the pixmap. The problem is if the pixmap has transparent parts (png images), then the item does not receive mouse events unless mouse is on top of actual…
Zheden
  • 583
  • 2
  • 11
  • 36
2
votes
3 answers

Qt | Creating a dynamic Chart / plot with QGraphicsView, QGraphics Scene | realtime data

I am currently developing a small programm in Qt. To show a plot you can use qwt or qcustomplot or the qpainterevent or QChart. But I am interessted in a solution for a dynamic plot which is writen with the QGraphicsView. My preferences -width of…
K.Friend
  • 31
  • 1
  • 8
2
votes
1 answer

qt graphicsscene line subclass

I added a Line subclass from the GraphicsScene class , to draw a line. From MainWindow I call the line function in that class, there are no errors, but the line isn't drawn. I know this must be lack of my c++ skills. But searching didn't help me on…
Jack Berkhout
  • 47
  • 1
  • 7
2
votes
1 answer

How to stop a middle mouse click from deselecting items in a QGraphicsScene without blocking it from items in the scene?

I am creating a node graph and I want to be able to click the empty space in a scene and middle-mouse-drag to navigate without deselecting the currently selected items in the scene. Any suggestions? I can block the middle click in the view's…
Rafe
  • 1,937
  • 22
  • 31
2
votes
2 answers

QGraphicsView slow with lots of QGraphicsPixmapItem

I've made a small code to test QGraphicsView capabilities using QtCreator. The code is quite simple, just created a class thats inherited from QGraphicsView that has a QGraphicsScene on it. Fill the scene with lots of QGraphicsPixmapItem (in this…
2
votes
1 answer

How to remove Ghost Lines drawn in qgraphicsview

I am trying to make a simple program in which I have added a qgraphics scene and in this I have added a QGraphicsRectItem. I have implemented mouse press event, paint event, bounding rect. Now I have drawn a point on one side of rectangle because…
sk110
  • 77
  • 2
  • 9
2
votes
1 answer

Constraining child QGraphicsItem to scene?

Does anyone have a better way to constrain a child of a QGraphicsItem to a scene? I have successfully properly constrained a parent QGraphicsItem to its scene by overriding itemChange, but now I need to do the same for the child…
Graeme Rock
  • 601
  • 5
  • 21
2
votes
0 answers

Printing really huge image on plotter using QPrinter

I have to print on plotter world map with a lot of vector data on it from Qt based app. Plotter has 80 GB hard drive, to print high resolution images. All data is loaded in QGraphicsScene. QGraphicsScene *scene; ..... QPrinter *printer = new…
Ujifman
  • 21
  • 3
2
votes
3 answers

How to change backgroundcolor of QLineEdit in a QGraphicsScene

I have a QGraphicsScene and add a QlineEdit but changing color just doesn't work. QGridLayout *layout = new QGridLayout(this); QGraphicsView *view = new QGraphicsView(this); QGraphicsScene *scene = new QGraphicsScene(this); QWidget *widget = new…
J.W.
  • 81
  • 10
2
votes
2 answers

PyQt. How to block clear selection on mouse right click?

I have a QGraphicsScene and many selectable items. But when I click the right mouse button - deselects all objects. I want show menu and edit selected objects but have automatic deselect any time when right click at mouse... Perhaps the problem is…
Massimo
  • 836
  • 3
  • 17
  • 38
2
votes
0 answers

PyQt's QGraphicsView.mapFromScene is behaving in a way I don't understand

I wrote the following example code to illustrate what it is that's confusing me: from PyQt4 import QtGui, QtCore import sys class Spam(QtGui.QWidget): def __init__(self): super(Spam, self).__init__() self.setGeometry(50, 50,…
sgfw
  • 285
  • 2
  • 14
2
votes
1 answer

How do you change the position of the boundingRect() of a QGraphicsItem on a QGraphicsScene?

I have set the boundingRect() of my QGraphicsItem to a certain coordinate on the scene. How can I change the coordinates based on the QGraphicsItem::mouseMoveEvent? Below is the code I have written. But this code only sets the position of the shape…
Alarming
  • 137
  • 1
  • 3
  • 14
2
votes
0 answers

How to implement MVC with QGraphicsScene as model?

I am struggling with the MVC concept. My current design: a subclass of QGraphicsScene, that implements a large number of properties: setPropertyAOnSelectedItems / getPropertyAOfSelectedItems setPropertyBOnScene / getPropertyBOfScene a…
Thalia
  • 13,637
  • 22
  • 96
  • 190
2
votes
1 answer

Understanding Interaction between QGraphicsItem boundingRect and shape Methods

I'm very experienced with Qt's QGraphicsScene, but I'm hoping someone can clarify a detail with regard to the boundingRect and shape methods for a QGraphicsItem. As far as I can find, the documentation doesn't address this specific concern. I have a…
goug
  • 2,294
  • 1
  • 11
  • 15
2
votes
1 answer

QMouseEvents in Graphics Scene not working

I am fairly new to Qt and creating a simple application that initializes a number of custom QGraphicsItems in a custom QGraphicsScene. Each item is initialized with a random start position and a Weight value which is dependent on the position of the…