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

Qt: The best procedure to create own QGraphicsScene/s

I'm making fractal creator software. So I need one scene per fractal and these scenes need to be "layered" because of zooming rubber band. I've already tried to write it the "widget" way, so I had one custom widget called "canvas". In my canvas…
Honza
  • 939
  • 2
  • 11
  • 28
1
vote
0 answers

increase scenerect with add item in qgraphicsview

I'm having a scene where items will be added continuously and out of specific sceneRect. items can be added infinite. ex: if I set the scene rect as (0, 0, 5000, 5000) there is a chance that an item can be added say pos (5010, 5010) so I cant able…
Wagmare
  • 1,354
  • 1
  • 24
  • 58
1
vote
0 answers

Slow scrolling of Qt QGraphicsView

I made a simple 2D game in Qt and deployed it to Android device. Main screen of the game is basically a QGraphicsView. Game world is represented by QGraphicsScene which is larger then the main screen. I used…
1
vote
0 answers

set Qwidget(dock widget) to a qgraphicscene-qt

I have 2 dock widgets where dock1 has the entire application. where i can zoom. and i want the replica of the same application in dock2 where it is fit to the screen. i am trying to add a Qgraphicscene to dock2 which loads the dock1 application.…
geek
  • 794
  • 3
  • 16
  • 41
1
vote
1 answer

Scaling positions of GraphicsItems on a GraphicsScene without changing other properties

I layout a bunch of nodes on a QGraphicsScene. The nodes are basic ellipses (QGraphicsEllipseItems). It works reasonably well. However I would like to know how to size the ellipses. Currently I have a hard-coded radius to 80 units this works fine…
user595985
  • 1,543
  • 4
  • 29
  • 55
1
vote
1 answer

What is the meaning of "the item's view geometry and scene geometry will be maintained separately"?

The documentation for the QGraphicsItem::ItemIgnoresTransformations flag says The item ignores inherited transformations (i.e., its position is still anchored to its parent, but the parent or view rotation, zoom or shear transformations are…
ederag
  • 2,409
  • 25
  • 49
1
vote
0 answers

Image shown twisted after PIL to QImage conversion

This block of code is to save the image data read from a byte array to the Image img val = bytearray(message.msg) size = re.split(r',', message.messageSize) img = Image.new("L", (int(size[0]), int(size[1])), 0) pix = img.load() counter = 0 for y in…
1
vote
1 answer

signal or event that notifies the viewport coordinate has changed from QGraphicsView

I am trying to implement a custom maps, which is consists on multiple tile images. I could successfully load tiles based on viewport Rect. void updateRasterTiles(const QRectF &viewport) { ..... Q_FOREACH(QString fileName, fileNames) { …
natiahc
  • 51
  • 5
1
vote
0 answers

Snapping in grid using qt

I have implemented grid in graphicsView using drawBackgroud method. Now I also want to add snap to the grid. By snap I mean that with mouse, you can't have point other than grid points. My code to grid drawn is as follows: void…
user3859872
  • 777
  • 2
  • 9
  • 16
1
vote
2 answers

Qt: issue with QGraphicscene to show an imge

I am trying to develop very simple image viewer using QT. I am using the following code to show the image on QGraphicsScene widget: QImage image(fileName); firstPicture = new…
Mohammad Saifullah
  • 1,113
  • 5
  • 16
  • 33
1
vote
2 answers

Find the center position of a QGraphicsScene?

I have tried to use the following code to add a line to my scene: line = new QGraphicsLineItem(200,55,200,55); mscene.addItem(ruler); But it seems the coordinate of the QGraphicsLineItem starts at the left corner. I don't want to alter the…
Nyaruko
  • 4,329
  • 9
  • 54
  • 105
1
vote
2 answers

Add a tiled base map to a GraphicsScene

I try to create a tiled base map by using Qt GUI: I have two classes: one to set my tile images that inherits from QGraphicPixmapItem, one to load my map from a text file that is a 2D array composed of the numbers 1, 0 and 2, and add it to a…
Ary
  • 128
  • 1
  • 1
  • 11
1
vote
1 answer

Can't get positions of QGraphicsItems in scene

I am trying to get the positions of the graphicsitems in the scene. But their QPointF value always remains (0,0). I am painting when mouse-click event occurs. On debugging scene->items(), I get (QGraphicsItem(this =0x22edff0, parent =0x0, pos…
Gurjot Bhatti
  • 977
  • 1
  • 10
  • 24
1
vote
0 answers

Using QPainter::CompositionMode with multiple overlapping QGraphicsItems

I have a QGraphicsScene with several MyQGraphicsItems, which I subclassed from QGraphicsItem, inside of it. Inside the paint event of MyQGraphicsItem, I have painter->drawImage(image_rect, m_image); so every MyQGraphicsItem presents a QImage to the…
hjweide
  • 11,893
  • 9
  • 45
  • 49
1
vote
2 answers

Why is this implementation of a QGraphicsScene causing the app to crash on exit?

I'm using Qt's Graphics View Framework to display a large number of images, and implementing it using PyQt4 and Python 2.7. I instantiate a number of QPixmapItem objects and add them to my QGraphicsScene. It all works as I'd expect it to until I…
Josh
  • 373
  • 4
  • 15