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
qgraphicslayoutitem.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QGRAPHICSLAYOUTITEM_H
5#define QGRAPHICSLAYOUTITEM_H
6
7#include <QtWidgets/qtwidgetsglobal.h>
8#include <QtCore/qscopedpointer.h>
9#include <QtWidgets/qsizepolicy.h>
10#include <QtGui/qevent.h>
11
12QT_REQUIRE_CONFIG(graphicsview);
13
15
17class QGraphicsItem;
18class Q_WIDGETS_EXPORT QGraphicsLayoutItem
19{
20public:
21 QGraphicsLayoutItem(QGraphicsLayoutItem *parent = nullptr, bool isLayout = false);
22 virtual ~QGraphicsLayoutItem();
23
24 void setSizePolicy(const QSizePolicy &policy);
26 QSizePolicy sizePolicy() const;
27
28 void setMinimumSize(const QSizeF &size);
29 inline void setMinimumSize(qreal w, qreal h);
30 QSizeF minimumSize() const;
31 void setMinimumWidth(qreal width);
32 inline qreal minimumWidth() const;
33 void setMinimumHeight(qreal height);
34 inline qreal minimumHeight() const;
35
36 void setPreferredSize(const QSizeF &size);
37 inline void setPreferredSize(qreal w, qreal h);
38 QSizeF preferredSize() const;
39 void setPreferredWidth(qreal width);
40 inline qreal preferredWidth() const;
41 void setPreferredHeight(qreal height);
42 inline qreal preferredHeight() const;
43
44 void setMaximumSize(const QSizeF &size);
45 inline void setMaximumSize(qreal w, qreal h);
46 QSizeF maximumSize() const;
47 void setMaximumWidth(qreal width);
48 inline qreal maximumWidth() const;
49 void setMaximumHeight(qreal height);
50 inline qreal maximumHeight() const;
51
52 virtual void setGeometry(const QRectF &rect);
53 QRectF geometry() const;
54 virtual void getContentsMargins(qreal *left, qreal *top, qreal *right, qreal *bottom) const;
55 QRectF contentsRect() const;
56
57 QSizeF effectiveSizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;
58
59 virtual void updateGeometry();
60
61 virtual bool isEmpty() const;
62 QGraphicsLayoutItem *parentLayoutItem() const;
63 void setParentLayoutItem(QGraphicsLayoutItem *parent);
64
65 bool isLayout() const;
66 QGraphicsItem *graphicsItem() const;
67 bool ownedByLayout() const;
68
69protected:
70 void setGraphicsItem(QGraphicsItem *item);
71 void setOwnedByLayout(bool ownedByLayout);
73
74 virtual QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const = 0;
75 QScopedPointer<QGraphicsLayoutItemPrivate> d_ptr;
76
77private:
78 QSizeF *effectiveSizeHints(const QSizeF &constraint) const;
79 Q_DECLARE_PRIVATE(QGraphicsLayoutItem)
80
81 friend class QGraphicsLayout;
82};
83
84#ifndef Q_QDOC
85Q_DECLARE_INTERFACE(QGraphicsLayoutItem, "org.qt-project.Qt.QGraphicsLayoutItem")
86#endif
87
89{ setMinimumSize(QSizeF(aw, ah)); }
91{ setPreferredSize(QSizeF(aw, ah)); }
93{ setMaximumSize(QSizeF(aw, ah)); }
94
96{ return effectiveSizeHint(Qt::MinimumSize).width(); }
98{ return effectiveSizeHint(Qt::MinimumSize).height(); }
99
101{ return effectiveSizeHint(Qt::PreferredSize).width(); }
103{ return effectiveSizeHint(Qt::PreferredSize).height(); }
104
106{ return effectiveSizeHint(Qt::MaximumSize).width(); }
108{ return effectiveSizeHint(Qt::MaximumSize).height(); }
109
111
112#endif
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
The QGraphicsLayoutItem class can be inherited to allow your custom items to be managed by layouts.
virtual QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint=QSizeF()) const =0
This pure virtual function returns the size hint for which of the QGraphicsLayoutItem,...
qreal maximumWidth() const
Returns the maximum width.
QScopedPointer< QGraphicsLayoutItemPrivate > d_ptr
void setMaximumSize(const QSizeF &size)
Sets the maximum size to size.
qreal minimumWidth() const
Returns the minimum width.
qreal preferredWidth() const
Returns the preferred width.
void setPreferredSize(const QSizeF &size)
Sets the preferred size to size.
void setMinimumSize(const QSizeF &size)
Sets the minimum size to size.
qreal maximumHeight() const
Returns the maximum height.
qreal minimumHeight() const
Returns the minimum height.
qreal preferredHeight() const
Returns the preferred height.
The QGraphicsLayout class provides the base class for all layouts in Graphics View.
\inmodule QtCore\reentrant
Definition qrect.h:484
\inmodule QtCore
Definition qsize.h:208
constexpr qreal width() const noexcept
Returns the width.
Definition qsize.h:332
constexpr qreal height() const noexcept
Returns the height.
Definition qsize.h:335
The QSizePolicy class is a layout attribute describing horizontal and vertical resizing policy.
Definition qsizepolicy.h:18
Policy
This enum describes the various per-dimension sizing types used when constructing a QSizePolicy.
Definition qsizepolicy.h:29
rect
[4]
Combined button and popup list for selecting options.
@ MaximumSize
@ PreferredSize
@ MinimumSize
#define Q_DECLARE_INTERFACE(IFace, IId)
Definition qobject.h:460
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLdouble GLdouble GLdouble GLdouble top
GLdouble GLdouble right
GLint GLsizei width
GLint left
GLint GLint bottom
GLfloat GLfloat GLfloat GLfloat h
#define QT_REQUIRE_CONFIG(feature)
double qreal
Definition qtypes.h:187
QGraphicsItem * item
QSizePolicy policy
widget setSizePolicy(policy)