Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
graphicssceneadditemsnippet.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4#include <QGraphicsEllipseItem>
5#include <QGraphicsScene>
6#include <QStyleOptionGraphicsItem>
7#include <QtGui>
8
10{
11public:
13 { addItem(new QGraphicsEllipseItem(QRect(10, 10, 30, 30))); }
14
15 void drawItems(QPainter *painter, int numItems, QGraphicsItem *items[],
16 const QStyleOptionGraphicsItem options[],
17 QWidget *widget = nullptr) override;
18};
19
23 const QStyleOptionGraphicsItem options[],
25{
26 for (int i = 0; i < numItems; ++i) {
27 // Draw the item
28 painter->save();
30 items[i]->paint(painter, &options[i], widget);
32 }
33}
void drawItems(QPainter *painter, int numItems, QGraphicsItem *items[], const QStyleOptionGraphicsItem options[], QWidget *widget=nullptr) override
[0]
The QGraphicsEllipseItem class provides an ellipse item that you can add to a QGraphicsScene.
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
The QGraphicsScene class provides a surface for managing a large number of 2D graphical items.
void addItem(QGraphicsItem *item)
Adds or moves the item and all its children to this scene.
The QPainter class performs low-level painting on widgets and other paint devices.
Definition qpainter.h:46
void restore()
Restores the current painter state (pops a saved state off the stack).
void save()
Saves the current painter state (pushes the state onto a stack).
void setTransform(const QTransform &transform, bool combine=false)
\inmodule QtCore\reentrant
Definition qrect.h:30
The QStyleOptionGraphicsItem class is used to describe the parameters needed to draw a QGraphicsItem.
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
QOpenGLWidget * widget
[1]
rect sceneTransform().map(QPointF(0
QList< QTreeWidgetItem * > items
QPainter painter(this)
[7]