14#if QT_CONFIG(sizegrip)
101 qWarning(
"QLayout: Attempting to add QLayout \"%ls\" to %s \"%ls\", which"
102 " already has a layout",
108 w->d_func()->layout =
this;
112 w->d_func()->layout =
nullptr;
120 :
QObjectPrivate(), insideSpacing(-1), userLeftMargin(-1), userTopMargin(-1), userRightMargin(-1),
121 userBottomMargin(-1), topLevel(
false),
enabled(true), activated(true), autoNewChild(
false),
132 if (userMargin >= 0) {
137 *
result = pw->style()->pixelMetric(pm,
nullptr, pw);
204 if (
item->widget() ==
w) {
227 if (
item->layout() == l) {
258 if (
d->insideSpacing >=0) {
259 return d->insideSpacing;
292 if (
d->userLeftMargin ==
left &&
d->userTopMargin ==
top &&
293 d->userRightMargin ==
right &&
d->userBottomMargin ==
bottom)
296 d->userLeftMargin =
left;
297 d->userTopMargin =
top;
298 d->userRightMargin =
right;
406 qWarning(
"QLayout::parentWidget: A layout can only have another layout as a parent.");
427 if (!
item->isEmpty())
442 QSizePolicy::ControlTypes
types;
443 for (
int i =
count() - 1;
i >= 0; --
i)
483 while ((
child = lay->itemAt(
i))) {
485 delete lay->takeAt(
i);
506 q->setGeometry(
rect);
507#if QT_CONFIG(menubar)
540#if QT_CONFIG(menubar)
542 d->menubar =
nullptr;
569 if (
QLayout *childLayout = qobject_cast<QLayout *>(e->
child()))
589#if QT_CONFIG(menubar)
611#if QT_CONFIG(menubar)
627 pw->ensurePolished();
634#if QT_CONFIG(menubar)
650 pw->ensurePolished();
659#if QT_CONFIG(menubar)
675 pw->ensurePolished();
682#if QT_CONFIG(menubar)
705 else if (
QLayout *parentLayout = qobject_cast<QLayout *>(
parent()))
722 qWarning(
"QLayout::addChildLayout: layout %s \"%ls\" already has a parent",
723 childLayout->metaObject()->className(),
qUtf16Printable(childLayout->objectName()));
726 childLayout->setParent(
this);
729 childLayout->d_func()->reparentChildWidgets(mw);
745static bool layoutDebug()
747 static int checked_env = -1;
748 if (checked_env == -1)
760#if QT_CONFIG(menubar)
765 bool mwVisible = mw && mw->isVisible();
766 for (
int i = 0;
i <
n; ++
i) {
771 if (
Q_UNLIKELY(pw && pw != mw && layoutDebug())) {
772 qWarning(
"QLayout::addChildLayout: widget %s \"%ls\" in wrong parent; moved to correct parent",
782 l->d_func()->reparentChildWidgets(mw);
795 qWarning(
"QLayout: Cannot add a null widget to %s/%ls",
q->metaObject()->className(),
800 qWarning(
"QLayout: Cannot add parent widget %s/%ls to its child layout %s/%ls",
816 qWarning(
"QLayout: Cannot add a null layout to %s/%ls",
821 qWarning(
"QLayout: Cannot add layout %s/%ls to itself",
849 qWarning(
"QLayout::addChildWidget: %s \"%ls\" is already in a layout; moved to new layout",
854 if (pw && mw && pw != mw) {
857 qWarning(
"QLayout::addChildWidget: %s \"%ls\" in wrong parent; moved to correct parent",
957 activateRecursiveHelper(
child);
958 layout->d_func()->activated =
true;
975 layout->d_func()->activated =
false;
976 if (
layout->d_func()->topLevel) {
1006 qWarning(
"QLayout::activate: %s \"%ls\" does not have a main widget",
1010 activateRecursiveHelper(
this);
1013 uint explMin = md->
extra ? md->extra->explicitMinSize : 0;
1014 uint explMax = md->extra ? md->extra->explicitMaxSize : 0;
1016 switch (
d->constraint) {
1034 if (mw->isWindow()) {
1037 ms.
setWidth(mw->minimumSize().width());
1039 ms.
setHeight(mw->minimumSize().height());
1040 mw->setMinimumSize(ms);
1041 }
else if (!widthSet || !heightSet) {
1042 QSize ms = mw->minimumSize();
1047 mw->setMinimumSize(ms);
1058 md->extra->explicitMinSize = explMin;
1059 md->extra->explicitMaxSize = explMax;
1062 mw->updateGeometry();
1100 for (
int u = 0; u <
count(); ++u) {
1105 if (
item->widget() == from) {
1121 newitem->setAlignment(
item->alignment());
1181 for (
int i = 0;
i <
c; ++
i) {
1200 for (
int i = 0;
i <
c; ++
i) {
1244 if (constraint ==
d->constraint)
1247 d->constraint = constraint;
1254 return d->constraint;
1277 QSize ms = that->maximumSize();
1278 that->setAlignment(
a);
1289 if (hfw <
s.height())
1293 s =
s.boundedTo(
r.size());
1298 y += (
r.height() -
s.height());
1300 y += (
r.height() -
s.height()) / 2;
1305 x += (
r.width() -
s.width());
1307 x += (
r.width() -
s.width()) / 2;
1309 return QRect(
x,
y,
s.width(),
s.height());
1326 qWarning(
"QLayout::removeWidget: Cannot remove a null widget.");
1407 if (current.
height() < currentHfw || currentHfw == newHfw) {
1410 result.setHeight(newHfw);
1421 while (minw < maxw) {
1422 if (minhfw > maxh) {
1423 minw = maxw - (maxw-minw)/2;
1425 }
else if (maxhfw < minh ) {
1426 maxw = minw + (maxw-minw)/2;
1440#include "moc_qlayout.cpp"
QObject * child() const
Returns the child object that was added or removed.
static void postEvent(QObject *receiver, QEvent *event, int priority=Qt::NormalEventPriority)
Type
This enum type defines the valid event types in Qt.
Type type() const
Returns the event type.
Qt::LayoutDirection layoutDirection
the default layout direction for this application
The QLayoutItem class provides an abstract item that a QLayout manipulates.
virtual bool hasHeightForWidth() const
Returns true if this layout's preferred height depends on its width; otherwise returns false.
virtual int heightForWidth(int) const
Returns the preferred height for this layout item, given the width, which is not used in this default...
Qt::Alignment alignment() const
Returns the alignment of this item.
virtual int minimumHeightForWidth(int) const
Returns the minimum height this widget needs for the given width, w.
virtual QWidget * widget() const
If this item manages a QWidget, returns that widget.
virtual QSize sizeHint() const =0
Implemented in subclasses to return the preferred size of this item.
virtual void invalidate()
Invalidates any cached information in this layout item.
bool checkLayout(QLayout *otherLayout) const
Returns true if the otherLayout can be added to the layout; otherwise returns false.
void getMargin(int *result, int userMargin, QStyle::PixelMetric pm) const
static QWidgetItem * createWidgetItem(const QLayout *layout, QWidget *widget)
bool checkWidget(QWidget *widget) const
Returns true if the widget can be added to the layout; otherwise returns false.
QWidgetItem *(* QWidgetItemFactoryMethod)(const QLayout *layout, QWidget *widget)
static QWidgetItemFactoryMethod widgetItemFactoryMethod
void reparentChildWidgets(QWidget *mw)
static QSpacerItem * createSpacerItem(const QLayout *layout, int w, int h, QSizePolicy::Policy hPolicy=QSizePolicy::Minimum, QSizePolicy::Policy vPolicy=QSizePolicy::Minimum)
static QSpacerItemFactoryMethod spacerItemFactoryMethod
QSpacerItem *(* QSpacerItemFactoryMethod)(const QLayout *layout, int w, int h, QSizePolicy::Policy hPolicy, QSizePolicy::Policy)
The QLayout class is the base class of geometry managers.
QRect geometry() const override
\reimp
QSize totalSizeHint() const
int totalHeightForWidth(int w) const
void widgetEvent(QEvent *)
void removeWidget(QWidget *w)
Removes the widget widget from the layout.
QSizePolicy::ControlTypes controlTypes() const override
\reimp
void addChildWidget(QWidget *w)
This function is called from addWidget() functions in subclasses to add w as a managed widget of a la...
void addWidget(QWidget *w)
Adds widget w to this layout in a manner specific to the layout.
int totalMinimumHeightForWidth(int w) const
void childEvent(QChildEvent *e) override
\reimp
void update()
Updates the layout for parentWidget().
bool isEmpty() const override
\reimp
bool isEnabled() const
Returns true if the layout is enabled; otherwise returns false.
QRect alignmentRect(const QRect &) const
Returns the rectangle that should be covered when the geometry of this layout is set to r,...
int spacing
the spacing between widgets inside the layout
QSize maximumSize() const override
Returns the maximum size of this layout.
void unsetContentsMargins()
QRect contentsRect() const
virtual void setSpacing(int)
SizeConstraint sizeConstraint
the resize mode of the layout
void setSizeConstraint(SizeConstraint)
bool activate()
Redoes the layout for parentWidget() if necessary.
virtual void addItem(QLayoutItem *)=0
Implemented in subclasses to add an item.
QSize totalMaximumSize() const
QSize totalMinimumSize() const
SizeConstraint
The possible values are:
void getContentsMargins(int *left, int *top, int *right, int *bottom) const
virtual QLayoutItem * itemAt(int index) const =0
Must be implemented in subclasses to return the layout item at index.
static QSize closestAcceptableSize(const QWidget *w, const QSize &s)
Returns a size that satisfies all size constraints on widget, including heightForWidth() and that is ...
virtual QLayoutItem * takeAt(int index)=0
Must be implemented in subclasses to remove the layout item at index from the layout,...
Qt::Orientations expandingDirections() const override
Returns whether this layout can make use of more space than sizeHint().
QLayout(QWidget *parent=nullptr)
Constructs a new top-level QLayout, with parent parent.
QSize minimumSize() const override
Returns the minimum size of this layout.
bool setAlignment(QWidget *w, Qt::Alignment alignment)
Sets the alignment for widget w to alignment and returns true if w is found in this layout (not inclu...
void invalidate() override
\reimp
virtual QLayoutItem * replaceWidget(QWidget *from, QWidget *to, Qt::FindChildOptions options=Qt::FindChildrenRecursively)
QWidget * menuBar() const
Returns the menu bar set for this layout, or \nullptr if no menu bar is set.
void setMenuBar(QWidget *w)
Tells the geometry manager to place the menu bar widget at the top of parentWidget(),...
QWidget * parentWidget() const
Returns the parent widget of this layout, or \nullptr if this layout is not installed on any widget.
void setEnabled(bool)
Enables this layout if enable is true, otherwise disables it.
virtual int count() const =0
Must be implemented in subclasses to return the number of items in the layout.
bool adoptLayout(QLayout *layout)
virtual void setGeometry(const QRect &) override
\reimp
QLayout * layout() override
\reimp
void addChildLayout(QLayout *l)
This function is called from addLayout() or insertLayout() functions in subclasses to add layout chil...
void removeItem(QLayoutItem *)
Removes the layout item item from the layout.
virtual int indexOf(const QWidget *) const
Searches for widget widget in this layout (not including child layouts).
void setContentsMargins(int left, int top, int right, int bottom)
constexpr int bottom() const noexcept
Returns the bottom margin.
constexpr int left() const noexcept
Returns the left margin.
constexpr int right() const noexcept
Returns the right margin.
constexpr int top() const noexcept
Returns the top margin.
static QObjectPrivate * get(QObject *o)
QObject * parent() const
Returns a pointer to the parent object.
QString objectName
the name of this object
void setParent(QObject *parent)
Makes the object a child of parent.
bool isWidgetType() const
Returns true if the object is a widget; otherwise returns false.
\inmodule QtCore\reentrant
constexpr int top() const noexcept
Returns the y-coordinate of the rectangle's top edge.
constexpr int left() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr int width() const noexcept
Returns the width of the rectangle.
constexpr void setTop(int pos) noexcept
Sets the top edge of the rectangle to the given y coordinate.
Policy
This enum describes the various per-dimension sizing types used when constructing a QSizePolicy.
constexpr QSize boundedTo(const QSize &) const noexcept
Returns a size holding the minimum width and height of this size and the given otherSize.
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
constexpr void setWidth(int w) noexcept
Sets the width to the given width.
constexpr void setHeight(int h) noexcept
Sets the height to the given height.
The QSpacerItem class provides blank space in a layout.
static Qt::Alignment visualAlignment(Qt::LayoutDirection direction, Qt::Alignment alignment)
Transforms an alignment of Qt::AlignLeft or Qt::AlignRight without Qt::AlignAbsolute into Qt::AlignLe...
PixelMetric
This enum describes the various available pixel metrics.
@ PM_LayoutHorizontalSpacing
Combined button and popup list for selecting options.
@ FindChildrenRecursively
static QT_BEGIN_NAMESPACE int menuBarHeightForWidth(QWidget *menubar, int w)
static bool removeWidgetRecursively(QLayoutItem *li, QObject *w)
Q_WIDGETS_EXPORT QSize qSmartMinSize(const QSize &sizeHint, const QSize &minSizeHint, const QSize &minSize, const QSize &maxSize, const QSizePolicy &sizePolicy)
Q_WIDGETS_EXPORT int qSmartSpacing(const QLayout *layout, QStyle::PixelMetric pm)
Q_WIDGETS_EXPORT QSize qSmartMaxSize(const QSize &sizeHint, const QSize &minSize, const QSize &maxSize, const QSizePolicy &sizePolicy, Qt::Alignment align)
QT_BEGIN_NAMESPACE constexpr int QLAYOUTSIZE_MAX
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qBound(const T &min, const T &val, const T &max)
constexpr const T & qMax(const T &a, const T &b)
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLsizei GLenum GLenum * types
GLdouble GLdouble GLdouble GLdouble top
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLfloat GLfloat GLfloat GLfloat h
GLdouble GLdouble GLdouble GLdouble q
static void layoutItem(QQuickItem *item, qreal y, qreal width)
#define qUtf16Printable(string)
Q_CORE_EXPORT int qEnvironmentVariableIntValue(const char *varName, bool *ok=nullptr) noexcept
const char className[16]
[1]
obj metaObject() -> className()