summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets/qabstractscrollarea.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/widgets/qabstractscrollarea.cpp')
-rw-r--r--src/widgets/widgets/qabstractscrollarea.cpp25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/widgets/widgets/qabstractscrollarea.cpp b/src/widgets/widgets/qabstractscrollarea.cpp
index 249ebd35d3..c6d66bafd4 100644
--- a/src/widgets/widgets/qabstractscrollarea.cpp
+++ b/src/widgets/widgets/qabstractscrollarea.cpp
@@ -334,16 +334,27 @@ void QAbstractScrollAreaPrivate::setSingleFingerPanEnabled(bool on)
void QAbstractScrollAreaPrivate::layoutChildren()
{
+ bool needH = false;
+ bool needV = false;
+ layoutChildren_helper(&needH, &needV);
+ // Call a second time if one scrollbar was needed and not the other to
+ // check if it needs to readjust accordingly
+ if (needH != needV)
+ layoutChildren_helper(&needH, &needV);
+}
+
+void QAbstractScrollAreaPrivate::layoutChildren_helper(bool *needHorizontalScrollbar, bool *needVerticalScrollbar)
+{
Q_Q(QAbstractScrollArea);
bool htransient = hbar->style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, hbar);
- bool needh = (hbarpolicy != Qt::ScrollBarAlwaysOff) && ((hbarpolicy == Qt::ScrollBarAlwaysOn && !htransient)
- || ((hbarpolicy == Qt::ScrollBarAsNeeded || htransient)
- && hbar->minimum() < hbar->maximum() && !hbar->sizeHint().isEmpty()));
+ bool needh = *needHorizontalScrollbar || ((hbarpolicy != Qt::ScrollBarAlwaysOff) && ((hbarpolicy == Qt::ScrollBarAlwaysOn && !htransient)
+ || ((hbarpolicy == Qt::ScrollBarAsNeeded || htransient)
+ && hbar->minimum() < hbar->maximum() && !hbar->sizeHint().isEmpty())));
bool vtransient = vbar->style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, vbar);
- bool needv = (vbarpolicy != Qt::ScrollBarAlwaysOff) && ((vbarpolicy == Qt::ScrollBarAlwaysOn && !vtransient)
- || ((vbarpolicy == Qt::ScrollBarAsNeeded || vtransient)
- && vbar->minimum() < vbar->maximum() && !vbar->sizeHint().isEmpty()));
+ bool needv = *needVerticalScrollbar || ((vbarpolicy != Qt::ScrollBarAlwaysOff) && ((vbarpolicy == Qt::ScrollBarAlwaysOn && !vtransient)
+ || ((vbarpolicy == Qt::ScrollBarAsNeeded || vtransient)
+ && vbar->minimum() < vbar->maximum() && !vbar->sizeHint().isEmpty())));
QStyleOption opt(0);
opt.init(q);
@@ -522,6 +533,8 @@ void QAbstractScrollAreaPrivate::layoutChildren()
viewportRect.adjust(left, top, -right, -bottom);
viewport->setGeometry(QStyle::visualRect(opt.direction, opt.rect, viewportRect)); // resize the viewport last
+ *needHorizontalScrollbar = needh;
+ *needVerticalScrollbar = needv;
}
/*!