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

Function: Getting clicked object from QGraphicsScene

I'm novice in programming and need a help. I have a class Station, which contains X and Y fields: Class Station { int x int y ... } All the stations are drawing on a QGraphicsScene as a circles and text: this->scene.addEllipse(x1, y1, diam, diam,…
Chernyavski.aa
  • 1,153
  • 1
  • 9
  • 16
2
votes
3 answers

qt QGraphicsScene additem

http://qt-project.org/doc/qt-4.8/qgraphicsscene.html#addItem said If the item is already in a different scene, it will first be removed from its old scene, and then added to this scene as a top-level. I want to keep the item in old scene. how…
Taeyun
  • 211
  • 2
  • 16
2
votes
2 answers

Remove path from QGraphicsScene

I am drawing a polygon on qgraphicsscene using QPainterPath. However after sometime when I want to delete the path I am unable to delete it. Can someone tell me how to delete/erase the drawn path. I am trying the following code. In header File: …
Sid411
  • 703
  • 2
  • 9
  • 25
2
votes
1 answer

Color the area defined by Items intersection in Qt

I have some custom QGraphicsItems in a QGraphicsView of a QGraphicsScene. With items(QPoint(x, y)) method I retrieve all the items at given scene point. Once these items are drawn they will not be moved, rotated or scaled, so their shapes will not…
diegob
  • 35
  • 6
2
votes
2 answers

QGraphicsView doesn't resize after pixmap scale, while pixmap not centered any more

I have created a QGraphicsView and inside it a QGraphicsScene. I load a pixmap in the QGraphicsScene. Actually it's an inherited QGraphicsScene which implements a wheelEvent in order to make the zoom in/out function. Zoom function scales the pixmap…
intergallactic
  • 138
  • 1
  • 11
2
votes
1 answer

Add qml object to QGraphicsScene

I try to add some QML object to my QGraphcisScene but they don't display in the scene. Here is the code. QList dataList; dataList.append(new DataObject("Item 1", "red")); dataList.append(new DataObject("Item 2",…
Mike Shaw
  • 373
  • 7
  • 22
2
votes
1 answer

How to work with QGraphicsScene::addPixmap when it only accepts const QPixmap?

I'd like to display some QImage through QGraphicsScene, my code's very straightforward: mainwindow.h QImage *sourceImage; QGraphicsView *imageView; QGraphicsScene *imageScene; mainwindow.cpp imageScene = new QGraphicsScene; imageView = new…
timfeirg
  • 1,426
  • 18
  • 37
2
votes
3 answers

how to create a pie chart with pyqt in python

Trying to create a pie chart shape but for some reason I can't get it to join together correctly. When I run my code It creates a lot of segments on top of each other. Here is my code: from PyQt4.QtCore import * from PyQt4.QtGui import * import sys,…
Tyroe
  • 21
  • 1
  • 2
2
votes
1 answer

Visual pixel-perfect selection in QGraphicsScene

I have a QGraphicsScene where I want the user to draw/move things around. Currently I can draw all the shapes I want (namely [un]filled rectangles and ellipses, lines and cubic bezier curves), deriving QGraphics*Item. I can also achieve selection on…
2
votes
1 answer

Detecting clicks on a QGraphicsItemGroup

I've been putting together an image-slider to animate images based on some pushbuttons. As an example for the effect I was looking for see the top of this page (http://www.menucool.com/slider/javascript-image-slider-demo4). I've succeeded in this…
2
votes
0 answers

Moving QGraphicsItem by mouse in a QGraphicsScene

I have a QGraphicsScene and its associated QGraphicsView. I let the user create some shapes in the form of derived QGraphicsItems into that scene. I also want them to be movable by mouse. Clicking one or more items select them, and moving them…
2
votes
2 answers

how to use mouse move event for QGraphicsScene?

hey want to drag this bezier curve when mouse button is pressed and moved.. I did this: void MainWindow::mouseMoveEvent(QMouseEvent *e) { qDebug()<<"in mouse move - outside if"; if((e->buttons() & Qt::RightButton) && isStart && enableDrag) { …
SSaurabhJ
  • 51
  • 1
  • 1
  • 8
2
votes
2 answers

Qt: QGraphicsLineItem position in QGraphicsScene

I have a problem with determining position of QGraphicsLineItem. I want to move items on the scene relatively, so I need to know their position. I have few QGraphicsPixmapItem objects and I do not have problem with them because pixmapItem.pos()…
speedyTeh
  • 247
  • 1
  • 8
  • 22
2
votes
1 answer

make 2 different selection-tools coexist in pyside

I am writing a program that lets users select items among a bunch of polygons in a QGraphicsScene. PySide provides a handy rubber-band selection tool but I wanted to be able to select items by drawing a polygon on the scene. To implement this I had…
2
votes
1 answer

QGraphicScene redraw on QGraphicItem move

I'm trying to fiddle a bit with a Qt example regarding 2D Graphics. Basically it is a small diagram editor. In the example, the author explains that the tracknodes() function is used to update the line's endpoints, when the user drags a connected…
Joum
  • 3,189
  • 3
  • 33
  • 64