23 return rect.adjusted(
priv->leftLayoutItemMargin,
priv->topLayoutItemMargin,
24 -
priv->rightLayoutItemMargin, -
priv->bottomLayoutItemMargin);
34 return rect.adjusted(-
priv->leftLayoutItemMargin, -
priv->topLayoutItemMargin,
35 priv->rightLayoutItemMargin,
priv->bottomLayoutItemMargin);
421 const QSize widgetRectSurplus =
r.size() -
rect.size();
444 pref += widgetRectSurplus;
449 s.setHeight(
qMin(
s.height(),
451 + widgetRectSurplus.
height()));
458 x =
x + (
r.width() -
s.width());
460 x =
x + (
r.width() -
s.width()) / 2;
463 y =
y + (
r.height() -
s.height());
465 y =
y + (
r.height() -
s.height()) / 2;
530 if (hfw < wid->minimumHeight())
559 if (hfw < wid->minimumHeight())
603 e &=
~Qt::Horizontal;
717inline bool QWidgetItemV2::useSizeCache()
const
719 return wid->d_func()->widgetItem ==
this;
722void QWidgetItemV2::updateCacheIfNecessary()
const
724 if (q_cachedMinimumSize.
width() != Dirty)
739 q_cachedMinimumSize = useLayoutItemRect
743 q_cachedSizeHint = expandedSizeHint;
746 q_cachedSizeHint = useLayoutItemRect
755 q_cachedMaximumSize = useLayoutItemRect
778 if (wd->widgetItem ==
this)
788 if (useSizeCache()) {
789 updateCacheIfNecessary();
790 return q_cachedSizeHint;
801 if (useSizeCache()) {
802 updateCacheIfNecessary();
803 return q_cachedMinimumSize;
814 if (useSizeCache()) {
815 updateCacheIfNecessary();
816 return q_cachedMaximumSize;
842 for (
int i = 0;
i < q_hfwCacheSize; ++
i) {
843 int offset = q_firstCachedHfw +
i;
846 if (q_hfwCacheSize == HfwCacheMaxSize)
847 q_firstCachedHfw =
offset % HfwCacheMaxSize;
848 return size.height();
852 if (q_hfwCacheSize < HfwCacheMaxSize)
854 q_firstCachedHfw = (q_firstCachedHfw + HfwCacheMaxSize - 1) % HfwCacheMaxSize;
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.
virtual ~QLayoutItem()
Destroys the QLayoutItem.
Qt::Alignment alignment() const
Returns the alignment of this item.
virtual QSpacerItem * spacerItem()
If this item is a QSpacerItem, it is returned as a QSpacerItem; otherwise \nullptr is returned.
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 void invalidate()
Invalidates any cached information in this layout item.
void setAlignment(Qt::Alignment a)
Sets the alignment of this item to alignment.
The QLayout class is the base class of geometry managers.
int totalHeightForWidth(int w) const
int totalMinimumHeightForWidth(int w) const
Qt::Orientations expandingDirections() const override
Returns whether this layout can make use of more space than sizeHint().
QLayout * layout() override
\reimp
static QObjectPrivate * get(QObject *o)
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
constexpr QSize size() const noexcept
Returns the size of the rectangle.
The QSizePolicy class is a layout attribute describing horizontal and vertical resizing policy.
constexpr Policy verticalPolicy() const noexcept
Returns the vertical component of the size policy.
ControlType controlType() const noexcept
constexpr bool retainSizeWhenHidden() const noexcept
constexpr Qt::Orientations expandingDirections() const noexcept
Returns whether a widget can make use of more space than the QWidget::sizeHint() function indicates.
constexpr Policy horizontalPolicy() const noexcept
Returns the horizontal component of the size policy.
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.
QSize sizeHint() const override
\reimp
QRect geometry() const override
\reimp
bool isEmpty() const override
Returns true.
QSpacerItem * spacerItem() override
Returns a pointer to this object.
~QSpacerItem()
Destructor.
QSize minimumSize() const override
\reimp
void setGeometry(const QRect &) override
\reimp
Qt::Orientations expandingDirections() const override
\reimp
QSize maximumSize() const override
\reimp
void changeSize(int w, int h, QSizePolicy::Policy hData=QSizePolicy::Minimum, QSizePolicy::Policy vData=QSizePolicy::Minimum)
Changes this spacer item to have preferred width w, preferred height h, horizontal size policy hPolic...
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...
Combined button and popup list for selecting options.
@ WA_LayoutUsesWidgetRect
const char * sizePolicy(int v)
Q_WIDGETS_EXPORT QSize qSmartMinSize(const QSize &sizeHint, const QSize &minSizeHint, const QSize &minSize, const QSize &maxSize, const QSizePolicy &sizePolicy)
Q_WIDGETS_EXPORT QSize qSmartMaxSize(const QSize &sizeHint, const QSize &minSize, const QSize &maxSize, const QSizePolicy &sizePolicy, Qt::Alignment align)
static QSize toLayoutItemSize(QWidgetPrivate *priv, const QSize &size)
static QT_BEGIN_NAMESPACE QRect fromLayoutItemRect(QWidgetPrivate *priv, const QRect &rect)
static QRect toLayoutItemRect(QWidgetPrivate *priv, const QRect &rect)
static QSize fromLayoutItemSize(QWidgetPrivate *priv, const QSize &size)
QT_BEGIN_NAMESPACE constexpr int QLAYOUTSIZE_MAX
constexpr const T & qMin(const T &a, const T &b)
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLuint GLintptr offset
GLfloat GLfloat GLfloat GLfloat h