Qt 4.8
qgraphicslayoutitem.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QGRAPHICSLAYOUTITEM_H
43 #define QGRAPHICSLAYOUTITEM_H
44 
45 #include <QtCore/qscopedpointer.h>
46 #include <QtGui/qsizepolicy.h>
47 #include <QtGui/qevent.h>
48 
50 
52 
53 QT_MODULE(Gui)
54 
55 #if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW
56 
58 class QGraphicsItem;
60 {
61 public:
62  QGraphicsLayoutItem(QGraphicsLayoutItem *parent = 0, bool isLayout = false);
63  virtual ~QGraphicsLayoutItem();
64 
65  void setSizePolicy(const QSizePolicy &policy);
66  void setSizePolicy(QSizePolicy::Policy hPolicy, QSizePolicy::Policy vPolicy, QSizePolicy::ControlType controlType = QSizePolicy::DefaultType);
67  QSizePolicy sizePolicy() const;
68 
69  void setMinimumSize(const QSizeF &size);
70  inline void setMinimumSize(qreal w, qreal h);
71  QSizeF minimumSize() const;
72  void setMinimumWidth(qreal width);
73  inline qreal minimumWidth() const;
74  void setMinimumHeight(qreal height);
75  inline qreal minimumHeight() const;
76 
77  void setPreferredSize(const QSizeF &size);
78  inline void setPreferredSize(qreal w, qreal h);
79  QSizeF preferredSize() const;
80  void setPreferredWidth(qreal width);
81  inline qreal preferredWidth() const;
82  void setPreferredHeight(qreal height);
83  inline qreal preferredHeight() const;
84 
85  void setMaximumSize(const QSizeF &size);
86  inline void setMaximumSize(qreal w, qreal h);
87  QSizeF maximumSize() const;
88  void setMaximumWidth(qreal width);
89  inline qreal maximumWidth() const;
90  void setMaximumHeight(qreal height);
91  inline qreal maximumHeight() const;
92 
93  virtual void setGeometry(const QRectF &rect);
94  QRectF geometry() const;
95  virtual void getContentsMargins(qreal *left, qreal *top, qreal *right, qreal *bottom) const;
96  QRectF contentsRect() const;
97 
98  QSizeF effectiveSizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;
99 
100  virtual void updateGeometry(); //### rename to sizeHintChanged()
101 
102  QGraphicsLayoutItem *parentLayoutItem() const;
103  void setParentLayoutItem(QGraphicsLayoutItem *parent);
104 
105  bool isLayout() const;
106  // ###Qt5: Make automatic reparenting work regardless of item/object/widget type.
107  QGraphicsItem *graphicsItem() const;
108  bool ownedByLayout() const;
109 
110 protected:
111  void setGraphicsItem(QGraphicsItem *item);
112  void setOwnedByLayout(bool ownedByLayout);
114 
115  virtual QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const = 0;
117 
118 private:
119  QSizeF *effectiveSizeHints(const QSizeF &constraint) const;
121 
123 };
124 
125 Q_DECLARE_INTERFACE(QGraphicsLayoutItem, "com.trolltech.Qt.QGraphicsLayoutItem")
126 
127 inline void QGraphicsLayoutItem::setMinimumSize(qreal aw, qreal ah)
128 { setMinimumSize(QSizeF(aw, ah)); }
130 { setPreferredSize(QSizeF(aw, ah)); }
132 { setMaximumSize(QSizeF(aw, ah)); }
133 
135 { return effectiveSizeHint(Qt::MinimumSize).width(); }
137 { return effectiveSizeHint(Qt::MinimumSize).height(); }
138 
140 { return effectiveSizeHint(Qt::PreferredSize).width(); }
142 { return effectiveSizeHint(Qt::PreferredSize).height(); }
143 
145 { return effectiveSizeHint(Qt::MaximumSize).width(); }
147 { return effectiveSizeHint(Qt::MaximumSize).height(); }
148 
149 #endif
150 
152 
154 
155 #endif
qreal maximumHeight() const
Returns the maximum height.
double qreal
Definition: qglobal.h:1193
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
QScopedPointer< QGraphicsLayoutItemPrivate > d_ptr
#define QT_MODULE(x)
Definition: qglobal.h:2783
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
qreal width() const
Returns the width.
Definition: qsize.h:284
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
qreal maximumWidth() const
Returns the maximum width.
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
Definition: qgraphicsitem.h:89
qreal height() const
Returns the height.
Definition: qsize.h:287
The QSizeF class defines the size of a two-dimensional object using floating point precision...
Definition: qsize.h:202
qreal minimumWidth() const
Returns the minimum width.
#define Q_DECLARE_INTERFACE(IFace, IId)
Definition: qobject.h:397
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
qreal preferredWidth() const
Returns the preferred width.
qreal minimumHeight() const
Returns the minimum height.
qreal preferredHeight() const
Returns the preferred height.
The QGraphicsLayoutItem class can be inherited to allow your custom items to be managed by layouts...
void setPreferredSize(const QSizeF &size)
Sets the preferred size to size.
SizeHint
Definition: qnamespace.h:1708
The QGraphicsLayout class provides the base class for all layouts in Graphics View.
Definition: qnamespace.h:54
#define Q_DECLARE_PRIVATE(Class)
Definition: qglobal.h:2467
#define class
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
#define QT_END_HEADER
Definition: qglobal.h:137
void setMaximumSize(const QSizeF &size)
Sets the maximum size to size.