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
2 answers

Move QGraphicsView top left to a certain point in QGraphicsScene manually

I have a QGraphicsView subclass, holding a QGraphicsScene subclass, inside a QWidget. The QGraphicsScene has an actual drawing rectangle with top let corner at (0,0) (so the scene really has a QRectF(-x,-y,w,h) of values irrelevant to the…
Thalia
  • 13,637
  • 22
  • 96
  • 190
1
vote
0 answers

How to draw bitmap from external file on the form?

I am using QT Creator 3.5.0 on Ubuntu 15.10. I have one form (mainwindow.ui) and I draw one GraphicView object (QGraphicsView) and one button (QPushButton). Signal on_pushButton_clicked() is created. How to draw image from external file (BMP/ JPG/…
1
vote
1 answer

How do I display a 2D numpy.ndarray as a collection of pixel values on a specific QGraphicsView?

How do I display a 2D numpy.ndarray as a collection of pixel values on a QGraphicsView? pylab.imshow() would typically be used at this point if I wasn't trying to make a GUI. frame = array([[ 56., 57., 58., ..., 58., 58., 58.], [ 52., …
Frikster
  • 2,755
  • 5
  • 37
  • 71
1
vote
1 answer

Printing QGraphicsScene cuts objects in half

I want to print everything what's on QGraphicsScene: void MainWindow::on_print_clicked() { if (template_ptr != Q_NULLPTR) { QPrinter printer(QPrinter::HighResolution); if (QPrintDialog(&printer, this).exec() == QDialog::Accepted)…
smsware
  • 429
  • 1
  • 13
  • 41
1
vote
0 answers

How to get default FBO between QPainter native painting?

I want to get the default FBO between QPainter's native painting area. such as: void QGraphicsScene::drawBackground(QPainter *painter, const QRectF &rect) { painter->beginNativePainting(); unsign int defaultFBO = getDefaultFBO(); // how ? …
WoodyWu
  • 11
  • 3
1
vote
1 answer

Qt QGraphicsScene visible scene rectangle

I am trying to design a custom widget with a QGraphicsScene and a pixmap item in it. I can see my item but there is a rectangle outside the scene. I found out that this is the scene rectangle. How can I prevent Qt from drawing scene…
Emrah
  • 13
  • 2
1
vote
1 answer

Saving a QGraphicsScene to Svg changes scaling

I need to save the items from my QGraphicsScene to an svg, and be able to load that svg back on the scene. I can do it... But each time the canvas is saved to svg, upon load the items are somewhat bigger (and repeatedly saving and loading the same…
Thalia
  • 13,637
  • 22
  • 96
  • 190
1
vote
1 answer

QGraphicsScene is calling QGraphicsItem paint event all the time

I have a QWidget which is holding a QGraphicsScene with several items. Some of those items are QGraphicsRectItems and subclassed QGraphicsItems. When in the scene there are QGraphicsRectItems only, the performance of the application is fine and the…
Agm
  • 11
  • 4
1
vote
2 answers

Setting background color of system background for widgets, on a QGraphicsScene

In my QGraphicsScene, I would like to set the background brush to the default widget background - but I can't get it. Kinda like, for my QGraphicsView, setBackgroundRole(QPalette::Window); or…
Thalia
  • 13,637
  • 22
  • 96
  • 190
1
vote
1 answer

Unexpected behaviour with QMouseMoveEvent and QKeyEvent modifiers

I am encountering unexpected behaviour in my code. I have a QGraphicsView containing a QGraphicsScene. Now I want to detect the mouse wheel for zooming the view and mouse moving for moving items in the scene, the latter only while controll is…
honiahaka10
  • 772
  • 4
  • 9
  • 29
1
vote
1 answer

Zooming out a QGraphicsView is crashing

I have a custom QGraphicsScene class that I want to scale when doing some mouse movements. The scaling works fine whenever the factor is >= 1.0. But when the factor is smaller than one, then it crashes because of (I believe a loop).Here is the code…
Laurent Crivello
  • 3,809
  • 6
  • 45
  • 89
1
vote
0 answers

QGraphicsScene: How to prevent keyboard events from reaching the main window while dragging items, for example?

I'm implementing a basic shape drawing tool using a custom subclass of Qt's QGraphicsScene and several QGraphicsItem. Now there are several situations where I don't want any "global" actions to be executed: For example, while dragging items around,…
ph4nt0m
  • 948
  • 4
  • 10
  • 23
1
vote
0 answers

Collision point detection in Qt Graphics Framework

I have a canvas in Qt (QGraphicsScene in QGraphicsView) on which user can add shapes: circle, square, rectangle, ellipse and triangle and change the size of either (as single QGraphicsObject subclass). Between these shapes user can create lines and…
Resurrection
  • 3,916
  • 2
  • 34
  • 56
1
vote
2 answers

How to get widgets (QGraphicsProxyWidget) of QGraphicsScene?

I am making use of a QGraphicsScene and I am adding regular widgets (QLineEdit, QComboBox, etc.) to it via implicitly created QGraphicsProxyWidget objects: m_pLineEdit = new QLineEdit("", 0); m_pProxy = m_pGraphicsScene->addWidget(m_pLineEdit); I…
Philip Allgaier
  • 3,505
  • 2
  • 26
  • 53
1
vote
0 answers

Cache efficient management of items in a QGraphicsScene

I have a QGraphicsScene which displays custom objects that inherit from QGraphicsItem. As an example, I want to display triangles that are made up like this: struct Triangle { Point a; Point b; Point c; }; The QGraphicsItem would look…
fuji
  • 1,173
  • 1
  • 10
  • 27