aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicklayouts/qquicklayout.cpp
diff options
context:
space:
mode:
authorJan Arve Sæther <jan-arve.saether@qt.io>2024-02-12 10:42:57 +0100
committerJan Arve Sæther <jan-arve.saether@qt.io>2024-05-28 13:22:14 +0000
commit0e9958d9eff3c3166b396ce6dc555abb0d0db8db (patch)
treef984d84aff3f7642a917aa5d78f7b538778dfb28 /src/quicklayouts/qquicklayout.cpp
parent82b5e84faf41c16c7160d26019252ddd8abb5912 (diff)
Enable layouts to respect other size policies than Fixed and Preferred
If no Layout.fillWidth/fillHeight is set, it will fallback to the default built-in size policies, which might be e.g. Expanding or Minimum Task-number: QTBUG-117597 Change-Id: I3cd43cdfb6b4beaefedb81605f52794afba55641 Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
Diffstat (limited to 'src/quicklayouts/qquicklayout.cpp')
-rw-r--r--src/quicklayouts/qquicklayout.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/quicklayouts/qquicklayout.cpp b/src/quicklayouts/qquicklayout.cpp
index f38bdfd396..a7955f7ab5 100644
--- a/src/quicklayouts/qquicklayout.cpp
+++ b/src/quicklayouts/qquicklayout.cpp
@@ -1253,29 +1253,29 @@ void QQuickLayout::effectiveSizeHints_helper(QQuickItem *item, QSizeF *cachedSiz
*/
QLayoutPolicy::Policy QQuickLayout::effectiveSizePolicy_helper(QQuickItem *item, Qt::Orientation orientation, QQuickLayoutAttached *info)
{
- bool fillExtent([&]{
- QLayoutPolicy::Policy policy{QLayoutPolicy::Fixed};
- if (item && QGuiApplication::testAttribute(Qt::AA_QtQuickUseDefaultSizePolicy)) {
- QLayoutPolicy sizePolicy = QQuickItemPrivate::get(item)->sizePolicy();
- policy = (orientation == Qt::Horizontal) ? sizePolicy.horizontalPolicy() : sizePolicy.verticalPolicy();
- }
- return (policy == QLayoutPolicy::Preferred);
- }());
-
+ QLayoutPolicy::Policy pol{QLayoutPolicy::Fixed};
bool isSet = false;
if (info) {
if (orientation == Qt::Horizontal) {
isSet = info->isFillWidthSet();
- if (isSet) fillExtent = info->fillWidth();
+ if (isSet && info->fillWidth())
+ pol = QLayoutPolicy::Preferred;
} else {
isSet = info->isFillHeightSet();
- if (isSet) fillExtent = info->fillHeight();
+ if (isSet && info->fillHeight())
+ pol = QLayoutPolicy::Preferred;
+ }
+ }
+ if (!isSet && item) {
+ if (qobject_cast<QQuickLayout*>(item)) {
+ pol = QLayoutPolicy::Preferred;
+ } else if (QGuiApplication::testAttribute(Qt::AA_QtQuickUseDefaultSizePolicy)) {
+ QLayoutPolicy sizePolicy = QQuickItemPrivate::get(item)->sizePolicy();
+ pol = (orientation == Qt::Horizontal) ? sizePolicy.horizontalPolicy() : sizePolicy.verticalPolicy();
}
}
- if (!isSet && qobject_cast<QQuickLayout*>(item))
- fillExtent = true;
- return fillExtent ? QLayoutPolicy::Preferred : QLayoutPolicy::Fixed;
+ return pol;
}
void QQuickLayout::_q_dumpLayoutTree() const