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

QGraphicsView shows nothing

I'm still learning Qt, I did a little project in Qt, i create a simple ui using qt ui designer, and using QGraphicsView to display a image loaded by QFileDialog, but when I added loaded image file to QgraphicsScene, the image is not displayed in the…
3
votes
2 answers

QGraphicsProxyWidget has clipped context menu in QGraphicsScene

The following code is based on the documentation of Graphics View Framework. I embed a QLineEdit in a QGraphicsScene and run the program. When I right click the line edit in the scene I get a clipped context menu. The context menu of a…
user1284878
  • 75
  • 1
  • 9
3
votes
1 answer

Get item's parent scene after QGraphicsScene::addItem ( QGraphicsItem * item )

I create a new QGraphicsItem named myItem. And in the mainwindow.cpp file I have a QGraphicsScene scene. In the constructor of mainwindow: ui->setupUi(this); scene = new QGraphicsScene(this); ui->graphicsView->setScene(scene); item = new…
lancellx
  • 285
  • 1
  • 5
  • 15
3
votes
0 answers

Setting drag mode over QGraphicsScene with QGraphicsWebView() in it

I have: self.setScene(QtGui.QGraphicsScene(self)) self.setTransformationAnchor(QtGui.QGraphicsView.AnchorUnderMouse) self.setDragMode(QtGui.QGraphicsView.ScrollHandDrag) where self is QGraphicsView. I am opening my svg in QGraphicsWebView()…
Aleksandar
  • 3,541
  • 4
  • 34
  • 57
3
votes
1 answer

How do i remove the selection drawing from a Qt QGraphicsTextItem

I am developing a Qt 4.8 application using QGraphicsScene on Windows XP. When the user double clicks on a QGraphicsTextItem, i call textItem->setTextInteractionFlags(Qt::TextEditorInteraction); At the next selection change i…
RED SOFT ADAIR
  • 12,032
  • 10
  • 54
  • 92
3
votes
2 answers

QGraphicsView->centerOn() doesn't work

I can't figure out how to make centerOn() to move viewport around the item (or the item around the port, not sure which way it is). The following code does work in…
Alex
  • 389
  • 2
  • 12
3
votes
1 answer

QGraphicsPixmapItem not selectable

I want my QGraphicsPixmapItem become selectable (i.e. clickable in more general way) on QGraphicScene but it doesn't. I'm actually modifying Qt's Diagram Scene sample, where QGraphicsItem's subclass is used and is selectable. I appreciate your…
IsaacS
  • 3,551
  • 6
  • 39
  • 61
3
votes
1 answer

How to correctly use QGraphicsLinearLayout together with QGraphicsScene in order to position QGraphicsItems?

I'm struggling with getting QGraphicsLinearLayout to work together with QGraphicsScene such that a group of QGraphicsItems are positioned in a linear fashion on the scene. I've tried using the approach below: #include #include…
gablin
  • 4,678
  • 6
  • 33
  • 47
3
votes
2 answers

QGraphicsScene::itemAt() - how to recognize custom classes

i have a little problem I am programming Petri Net simulator... I have two different classes class PNItem : public QObject, public QGraphicsItem ... and class PNEdge : public QGraphicsLineItem when i call... QGraphicsItem…
Marty
  • 95
  • 2
  • 9
2
votes
1 answer

Viewing entire QGraphicsScene

I'm trying to write a map editor in Qt, using QGraphicsView and QGraphicsScene for both the map and tile sheets. The problem I'm having right now is with making a good widget for importing tiles. For this, I'm using a QTabWidget (for different tile…
Rikonator
  • 1,830
  • 16
  • 27
2
votes
1 answer

Why do my my line widths looks different in a QGraphicsScene with the same QPen width?

I use a QPainter to draw my widget with this code: QPen pen(Qt::black, 0.6, Qt::SolidLine); QPainter painter(this); painter.setPen(pen); // vertical painter.drawLine(startX,0,startX,50); painter.drawLine((startX +=…
nils
  • 97
  • 1
  • 8
2
votes
2 answers

About the efficiency issus of Qt Graphics View Framework when there are vast items

Recently, i develop a new visualization software using the QT Grapohics View Framework. In the software, we need show a lot of items, include the point and line, about ten thousand above. But, in the process of display , there are pool efficiency…
2
votes
1 answer

Redefine QPainter options when redrawing QGraphicsItem

I want to redefine the QPainter before drawing earch QGraphicsItem in a QGraphics scene. void GraphicsScene::drawItems( QPainter * painter, int nbItem, QGraphicsItem *[] items, const QStyleOptionGraphicsItem[] options, QWidget * widget = NULL ) Is…
Matthieu Riegler
  • 31,918
  • 20
  • 95
  • 134
2
votes
2 answers

Qt4: QGraphicsScene/View and custom transformation method?

I know that it is possible to use affine transformations with Qt. But is it also possible to set a complete custom global transformation method? Use case: Drawing projected geographic points (lat, long) or retrieve mouse events etc. in geographic…
wal-o-mat
  • 7,158
  • 7
  • 32
  • 41
2
votes
1 answer

Drag and Drop between different QGraphicsView's

I have a QMainWindow with two QGraphicsView's each owning a QGraphicsScene. Both views are displayed (on screen) constantly. I would like to be able to drag and drop objects (objects of a class subclassed from QGraphicsItem) from one QGraphicsView…
mmvie
  • 2,571
  • 7
  • 24
  • 39