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)
506 q->setGeometry(
rect);
507#if QT_CONFIG(menubar)
539#if QT_CONFIG(menubar)
541 d->menubar =
nullptr;
568 if (
QLayout *childLayout = qobject_cast<QLayout *>(
e->child()))
588#if QT_CONFIG(menubar)
610#if QT_CONFIG(menubar)
633#if QT_CONFIG(menubar)
658#if QT_CONFIG(menubar)
681#if QT_CONFIG(menubar)
704 else if (
QLayout *parentLayout = qobject_cast<QLayout *>(
parent()))
721 qWarning(
"QLayout::addChildLayout: layout %s \"%ls\" already has a parent",
728 childLayout->d_func()->reparentChildWidgets(mw);
744static bool layoutDebug()
746 static int checked_env = -1;
747 if (checked_env == -1)
759#if QT_CONFIG(menubar)
765 for (
int i = 0;
i <
n; ++
i) {
770 if (
Q_UNLIKELY(pw && pw != mw && layoutDebug())) {
771 qWarning(
"QLayout::addChildLayout: widget %s \"%ls\" in wrong parent; moved to correct parent",
781 l->d_func()->reparentChildWidgets(mw);
794 qWarning(
"QLayout: Cannot add a null widget to %s/%ls",
q->metaObject()->className(),
799 qWarning(
"QLayout: Cannot add parent widget %s/%ls to its child layout %s/%ls",
815 qWarning(
"QLayout: Cannot add a null layout to %s/%ls",
820 qWarning(
"QLayout: Cannot add layout %s/%ls to itself",
848 qWarning(
"QLayout::addChildWidget: %s \"%ls\" is already in a layout; moved to new layout",
853 if (pw && mw && pw != mw) {
856 qWarning(
"QLayout::addChildWidget: %s \"%ls\" in wrong parent; moved to correct parent",
956 activateRecursiveHelper(
child);
957 layout->d_func()->activated =
true;
974 layout->d_func()->activated =
false;
975 if (
layout->d_func()->topLevel) {
1005 qWarning(
"QLayout::activate: %s \"%ls\" does not have a main widget",
1009 activateRecursiveHelper(
this);
1015 switch (
d->constraint) {
1040 }
else if (!widthSet || !heightSet) {
1057 md->
extra->explicitMinSize = explMin;
1058 md->
extra->explicitMaxSize = explMax;
1099 for (
int u = 0; u <
count(); ++u) {
1104 if (
item->widget() == from) {
1180 for (
int i = 0;
i <
c; ++
i) {
1199 for (
int i = 0;
i <
c; ++
i) {
1243 if (constraint ==
d->constraint)
1246 d->constraint = constraint;
1253 return d->constraint;
1288 if (hfw <
s.height())
1292 s =
s.boundedTo(
r.size());
1297 y += (
r.height() -
s.height());
1299 y += (
r.height() -
s.height()) / 2;
1304 x += (
r.width() -
s.width());
1306 x += (
r.width() -
s.width()) / 2;
1308 return QRect(
x,
y,
s.width(),
s.height());
1325 qWarning(
"QLayout::removeWidget: Cannot remove a null widget.");
1406 if (current.
height() < currentHfw || currentHfw == newHfw) {
1409 result.setHeight(newHfw);
1420 while (minw < maxw) {
1421 if (minhfw > maxh) {
1422 minw = maxw - (maxw-minw)/2;
1424 }
else if (maxhfw < minh ) {
1425 maxw = minw + (maxw-minw)/2;
1439#include "moc_qlayout.cpp"
static void postEvent(QObject *receiver, QEvent *event, int priority=Qt::NormalEventPriority)
Qt::LayoutDirection layoutDirection
the default layout direction for this application
The QLayoutItem class provides an abstract item that a QLayout manipulates.
virtual QSizePolicy::ControlTypes controlTypes() const
Returns the control type(s) for the layout item.
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...
virtual QLayout * layout()
If this item is a QLayout, it is returned as a QLayout; otherwise \nullptr is returned.
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.
void setAlignment(Qt::Alignment a)
Sets the alignment of this item to alignment.
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 QSize expandedTo(const QSize &) const noexcept
Returns a size holding the maximum width and height of this size and the given otherSize.
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.
@ WA_WState_ExplicitShowHide
@ 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()
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent