aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-09-29 15:58:07 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2016-09-30 08:31:24 +0000
commitb4ce31415baba84ca82aec68f4480b3e6ac89b90 (patch)
tree6984bb3adc85564e7f7ac8ed5c80861a392323b1 /src
parent7433cc2f91d1aba045ab4920d6732c85d2ee33b9 (diff)
TabBar: fix mixing of fixed and implicitly resized tabs
Don't calculate the implicit item width based on the total width of the whole control, but based on the available width that is left after subtracting the items that have an explicit width and won't be resized. Change-Id: Iae18dd9c9756b6f2afa143baab7d2501ce9d4697 Task-number: QTBUG-56265 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/quicktemplates2/qquicktabbar.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/quicktemplates2/qquicktabbar.cpp b/src/quicktemplates2/qquicktabbar.cpp
index 6fe734bb..bf6c4e74 100644
--- a/src/quicktemplates2/qquicktabbar.cpp
+++ b/src/quicktemplates2/qquicktabbar.cpp
@@ -113,16 +113,28 @@ void QQuickTabBarPrivate::updateLayout()
Q_Q(QQuickTabBar);
const int count = contentModel->count();
if (count > 0 && contentItem) {
- const qreal itemWidth = (contentItem->width() - qMax(0, count - 1) * spacing) / count;
+ qreal reservedWidth = 0;
+ QVector<QQuickItem *> resizableItems;
+ resizableItems.reserve(count);
for (int i = 0; i < count; ++i) {
QQuickItem *item = q->itemAt(i);
if (item) {
QQuickItemPrivate *p = QQuickItemPrivate::get(item);
- if (!p->widthValid) {
- item->setWidth(itemWidth);
- p->widthValid = false;
- }
+ if (!p->widthValid)
+ resizableItems += item;
+ else
+ reservedWidth += item->width();
+ }
+ }
+
+ if (!resizableItems.isEmpty()) {
+ const qreal totalSpacing = qMax(0, count - 1) * spacing;
+ const qreal itemWidth = (contentItem->width() - reservedWidth - totalSpacing) / resizableItems.count();
+
+ for (QQuickItem *item : qAsConst(resizableItems)) {
+ item->setWidth(itemWidth);
+ QQuickItemPrivate::get(item)->widthValid = false;
}
}
}