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

Zoom on mouse position QGraphicsView

I am looking to find how to zoom in a QGraphicsView but on the cursor position. Currently I am able to zoom but the position it is zooming onto is not consistent. def wheelEvent(self, event): '''Wheel event to zoom ''' …
Adam Baker
  • 44
  • 8
1
vote
1 answer

GST (gstreamer) command in QMediaPlayer command

I am using Qt Creator 4.5.2 (Qt 5.9.5, GCC 7.3.0 64-bit) and running on Ubuntu 18.04 I am just trying to get live video stream from a IP camera. I used 'QGraphicsView', 'QGraphicsScene', 'QGraphicsVideoItem' and QMediaPlayer methods. Right now, the…
Steven Cao
  • 83
  • 2
  • 7
1
vote
1 answer

QAction as keyboard shortcut on QGraphicsItem

I would like to implement keyboard shortcuts for my QGraphicsScene. My graphical objects are derived from QGraphicItem and QObject, so I can use signal/slot connections. I'm already using QActions for context menus and now I would like to use some…
Ludek Vodicka
  • 1,610
  • 1
  • 18
  • 33
1
vote
1 answer

QGraphicsAnchorLayout not anchoring in QGraphicsScene

I am currently having issues understanding the behavior of QGraphicsAnchorLayout within a QGraphicsScene. I create 4 boxes and anchor the corners of each, but no anchors appear to be applied properly, or at least the way I believed they would…
HonestMath
  • 325
  • 1
  • 2
  • 10
1
vote
1 answer

How to properly scale GraphicsScene

I've created a small app and I'm trying to make it so that when the main window is resized (and the GraphicsView and scene are too) that the whole scene (pixmap and rectangles) scale vertically to fit completely inside the GraphicsView. I don't…
Gene
  • 97
  • 2
  • 7
1
vote
0 answers

Scale items position relative to the scene/view resizing

I'm developing a software using Qt. I have a QGraphicsView that can be resized. I want to let users load an image (some maps) as the background of the view and be able to place some markers on the image (QGraphicsPixmapItem) and move them around.…
Mosi
  • 1,178
  • 2
  • 12
  • 30
1
vote
1 answer

Show X and Y coordinates lines in QGraphicsView

I want to display an image in a QGraphicsView, actually in QGraphicsScene, this is the easy part, bu, when I move the cursor over the image, I want to see the X and Y coordinates lines (the yellow lines), like in this image, can anyone explain me…
Vesa95
  • 607
  • 1
  • 7
  • 26
1
vote
1 answer

Implementing one dimensional drag operation in Qt

I want to allow a QGraphicsItem to be dragged only in certain directions, such as +/-45 degrees, horizontally or vertically, and to be able to "jump" to a new direction once the cursor is dragged far enough away from the current closest direction.…
Sean
  • 1,346
  • 13
  • 24
1
vote
1 answer

What's the best way to implement interactive spline-like curve on QGraphicsView?

I'm developing application which would allow user to upload an image of a rock crack and apply spline approximation to that crack. For that purpose i have QGraphicsView, that displays an uploaded image. Once image is uploaded, user has an option…
George
  • 578
  • 4
  • 21
1
vote
1 answer

New QPixmap seems to overlay old QPixmap

I want to display some images on my GUI, first when I click on the button, to select first image, everything act normal, my image is displayed fitInView, but when I want to select the next image, dark magic happens.. my second image is not in center…
Vesa95
  • 607
  • 1
  • 7
  • 26
1
vote
1 answer

Fit QGraphisItem in view

Is a method to fit any image in view (that I import in QPixmap) and keep aspect ratio>. I try many solution but non of those works. Also I don't not sure what I need to fit? QGraphicsScene in QGraphicsView? Or QPixmap in QGraphicsView? from PyQt5…
Vesa95
  • 607
  • 1
  • 7
  • 26
1
vote
1 answer

Is there QLabel::setScaledContents equivalent function for QGraphicsScene in Qt?

I'm using QGraphicsView and QGraphicsScene to display an uploaded image and then show some drawing on it. I'm uploading and image like so: void MeasuresWidget::on_openAction_triggered() { QString fileName =…
George
  • 578
  • 4
  • 21
1
vote
1 answer

How to change the color of the rectangle when you click on the button "Color"

I need to make a color selection for a rectangle using QColorDialog. When I click on the color select button and choose a color, the color of the rectangle changes import sys from PyQt5.QtCore import Qt, QRectF, QPointF from PyQt5.QtGui import…
1
vote
1 answer

Add ports to the QGraphicsPixmapItem object

I've created something like this. I have created a QGraphicsPixmapItem object that I can add to QGraphicsView. I want to add ports to these objects I created. And I want to make connections between these ports and the objects I have created. I…
1
vote
1 answer

Converting points between coordinates of two QGraphicsItem's in a scene

I'm having difficulty converting points in the coordinates of one item to the coordinates of another item, like so from PySide import QtGui, QtCore import sys class Editor(QtGui.QMainWindow): def __init__(self, parent=None): …
Olumide
  • 5,397
  • 10
  • 55
  • 104