summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/widgets/widgets/qtabbar.cpp18
-rw-r--r--tests/manual/qtabbar/main.cpp18
2 files changed, 26 insertions, 10 deletions
diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp
index b9020253a5..85bc9a4a09 100644
--- a/src/widgets/widgets/qtabbar.cpp
+++ b/src/widgets/widgets/qtabbar.cpp
@@ -447,9 +447,10 @@ void QTabBarPrivate::layoutTabs()
QVector<QLayoutStruct> tabChain(tabList.count() + 2);
// We put an empty item at the front and back and set its expansive attribute
- // depending on tabAlignment.
+ // depending on tabAlignment and expanding.
tabChain[tabChainIndex].init();
- tabChain[tabChainIndex].expansive = (tabAlignment != Qt::AlignLeft)
+ tabChain[tabChainIndex].expansive = (!expanding)
+ && (tabAlignment != Qt::AlignLeft)
&& (tabAlignment != Qt::AlignJustify);
tabChain[tabChainIndex].empty = true;
++tabChainIndex;
@@ -514,13 +515,12 @@ void QTabBarPrivate::layoutTabs()
maxExtent = maxWidth;
}
- if (!expanding) {
- // Mirror our front item.
- tabChain[tabChainIndex].init();
- tabChain[tabChainIndex].expansive = (tabAlignment != Qt::AlignRight)
- && (tabAlignment != Qt::AlignJustify);
- tabChain[tabChainIndex].empty = true;
- }
+ // Mirror our front item.
+ tabChain[tabChainIndex].init();
+ tabChain[tabChainIndex].expansive = (!expanding)
+ && (tabAlignment != Qt::AlignRight)
+ && (tabAlignment != Qt::AlignJustify);
+ tabChain[tabChainIndex].empty = true;
Q_ASSERT(tabChainIndex == tabChain.count() - 1); // add an assert just to make sure.
// Do the calculation
diff --git a/tests/manual/qtabbar/main.cpp b/tests/manual/qtabbar/main.cpp
index b1ef0df100..5a1a558c10 100644
--- a/tests/manual/qtabbar/main.cpp
+++ b/tests/manual/qtabbar/main.cpp
@@ -56,12 +56,28 @@
#include <QLayout>
#include <QDesktopWidget>
#include <QTabWidget>
+#include <QProxyStyle>
+
+class MyProxyStyle : public QProxyStyle
+{
+public:
+ int styleHint(StyleHint hint, const QStyleOption *option = 0,
+ const QWidget *widget = 0, QStyleHintReturn *returnData = 0) const
+ {
+ if (hint == QStyle::SH_TabBar_Alignment)
+ return Qt::AlignLeft;
+// return Qt::AlignRight;
+// return Qt::AlignCenter;
+ return QProxyStyle::styleHint(hint, option, widget, returnData);
+ }
+};
const int TabCount = 5;
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
+ app.setStyle(new MyProxyStyle);
QWidget widget;
QStackedWidget stackedWidget;
@@ -69,7 +85,7 @@ int main(int argc, char *argv[])
tabBar.setDocumentMode(true);
tabBar.setTabsClosable(true);
tabBar.setMovable(true);
- tabBar.setExpanding(true);
+ tabBar.setExpanding(false);
// top
tabBar.setShape(QTabBar::RoundedNorth);