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

How to set the back ground brush of a QGraphicsScene with a style sheet

Is it possible to set the background brush of a QGraphicsScene with a Qt style sheet? I tried QGraphicsScene { background-color: #f00; } but it doesn't work. Is it possible to use stylesheets in the Qt Graphics View framework at all?
Ralph Tandetzky
  • 22,780
  • 11
  • 73
  • 120
0
votes
2 answers

How do I display a PGM file within a QGraphicsView?

I am trying to display a PGM file using the following test application. The code works with a PNG file, but not PGM: import sys from PyQt4.QtGui import * from PyQt4.QtCore import * import Image import ImageQt class MyView(QGraphicsView): def…
0
votes
1 answer

QPixmap image file not appear on QGraphicsScene

By modifying Qt's Diagram Scene sample, I want my window to display an overlay object when a user clicks on a region that's described by GraphicalScene (original sample shows instead QPolygon). In the following code I'm using QPixmap. However…
IsaacS
  • 3,551
  • 6
  • 39
  • 61
0
votes
1 answer

How to put several QImage in a QGraphicsView?

I have a scene where several items are added. The problem is that when the items are displayed, they are overlapping. Is there any way to indicate in the QGraphicsView or QGraphicsScene the position where each item should appear?
jackajack
  • 153
  • 1
  • 1
  • 11
0
votes
1 answer

How to identify certain QGraphicItems in a QGraphicsScene

I have several QGraphicItems in a QGraphicsScene. I want to modify only some of them when the QGraphicsView containing the scene gets resized. The reason is that I have painted a grid respective to the view. So how can I identify the items making up…
HWende
  • 1,705
  • 4
  • 18
  • 30
0
votes
1 answer

Point 0/0 of QGraphicsItem.scene() (restricting item movement)

I have a problem limiting the move of my QGraphicItems: QVariant CustomRectItem::itemChange(GraphicsItemChange change, const QVariant& value) { if (change == QGraphicsItem::ItemPositionChange && this->scene()) { // parameter value is…
HWende
  • 1,705
  • 4
  • 18
  • 30
0
votes
1 answer

Shifting a QGraphicsItem's "graphic"

I have a QGraphicsItem with a custom graphic as shown below in the top half of the figure, where the red circle is the shape() of the item: Is there a way to preserve the graphic but just shift it like shown in the bottom half of the figure?
JustinBlaber
  • 4,629
  • 2
  • 36
  • 57
0
votes
1 answer

Qt: QGraphicObject and QImage

I have a QGraphicsObject derived class that holds a QImage and ovveride paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) In the pain I succefully draw the QImage. The QGraphicsObject is an item of QGraphicsScene,…
Blackbelt
  • 156,034
  • 29
  • 297
  • 305
0
votes
1 answer

Reposition graphics items on window resize

Ok, I basically have randomly placed graphics items on a graphics scene. I open a window and display these items. When I resize the window, I want this items to stay the same size but reposition proportionally to the window size. How I did this was…
JustinBlaber
  • 4,629
  • 2
  • 36
  • 57
0
votes
1 answer

Embedded Qt GraphicsScene coordinates

Resolved. I'm creating a fullscreen app with C++ and Qt. In the screen l have a graphicsScene (and a View for it) that takes out a section of the screen. l can't figure out how to get the coordinates right. l want the view size to match the size of…
deprecated
  • 57
  • 1
  • 7
0
votes
1 answer

Animated GUI with Qt and mouse hover on QGraphicsTextItem

I'm trying to make my own animated GUI with the help of Qt 4.8 on Windows. At the beginning i used the widgets and the Qt Designer to place a horizontal/grid/etc layout and put inside the normal widgets but I found that making them move with the…
Stefano
  • 3,213
  • 9
  • 60
  • 101
-1
votes
1 answer

Problem with QGraphicsPolygonItem and drag their corners with mouse after move

i have been working on a QT application using the QGraphicsPolygonItem. First i created a class called DiagramScene who inherites the QGraphicsScene. First i create the item and put red corners in every point of the Polygon: item = new…
-1
votes
1 answer

How to get current visible portion of QGraphicsView in Qt?

I have QGraphicsView, which has multiple QGraphicsItem's. On this view, I am applying some transformation using features like Zoom-in, zoom-out, fit -In etc. So before applying fit-in feature on my current view, I want to store view's current…
tushar
  • 313
  • 4
  • 10
-1
votes
1 answer

QT scene->removeItem (* QgraphicsItem) removes the object from the scene but it is still observed

I am creating a simple game using QT c ++, I have an asteroid class and a Qvector of said class. Every 15 seconds an asteroid is created and added to the Qvector. void MainWindow::generarAsteroides(){ srand(time(NULL)); int…
-1
votes
1 answer

How to properly drop a widget on a QGraphicsView right under the mouse?

Following my previous post I have been trying to solve a positioning problem withing a QGraphicsView. After a widget is dragged from a QListWidget and dropped inside a QGraphicsView, it jumps everywhere. The problem I have been trying to solve with…
Emanuele
  • 2,194
  • 6
  • 32
  • 71