summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets
diff options
context:
space:
mode:
authorStanislav Yelenskiy <qt@devstas.com>2020-09-25 00:17:28 +0200
committerTarja Sundqvist <tarja.sundqvist@qt.io>2021-02-02 10:56:37 +0200
commit404b0cc60a65dedbcdc3417f567d9b21c55c359b (patch)
tree2cdd6f5eea1cd457da4ef455b841ed9393a32e39 /src/widgets/widgets
parent4699abaedca56c735cdc59f0ef217629e26b9192 (diff)
QTabBar: update index of last visible tab in insertTab
Index of the last visible tab was not updated, if a new tab was inserted after the current tab and before the last tab. When the new tab is inserted before the last visible tab, the index of the last tab increments by one. When the new tab is inserted after the last visible tab, then the newly inserted tab becomes the last visible. Fixes: QTBUG-86898 Change-Id: I2f4b7f705261ec35a5aa7b883ecdddba25f007b7 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit b39b018f4a54252ee7a9ffada6d0f05f5896baaf)
Diffstat (limited to 'src/widgets/widgets')
-rw-r--r--src/widgets/widgets/qtabbar.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp
index 7ddd3c6c24..3324f7c6b4 100644
--- a/src/widgets/widgets/qtabbar.cpp
+++ b/src/widgets/widgets/qtabbar.cpp
@@ -997,14 +997,16 @@ int QTabBar::insertTab(int index, const QIcon& icon, const QString &text)
d->tabList[index].shortcutId = grabShortcut(QKeySequence::mnemonic(text));
#endif
d->firstVisible = qMax(qMin(index, d->firstVisible), 0);
- d->lastVisible = qMax(index, d->lastVisible);
d->refresh();
if (d->tabList.count() == 1)
setCurrentIndex(index);
- else if (index <= d->currentIndex) {
+ else if (index <= d->currentIndex)
++d->currentIndex;
+
+ if (index <= d->lastVisible)
++d->lastVisible;
- }
+ else
+ d->lastVisible = index;
if (d->closeButtonOnTabs) {
QStyleOptionTabV4 opt;