summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/io/qprocess/tst_qprocess.cpp2
-rw-r--r--tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp6
-rw-r--r--tests/auto/gui/image/qimagereader/tst_qimagereader.cpp76
-rw-r--r--tests/auto/tools/moc/cxx17-namespaces.h64
-rw-r--r--tests/auto/tools/moc/moc.pro2
-rw-r--r--tests/auto/tools/moc/tst_moc.cpp25
-rw-r--r--tests/auto/tools/uic/baseline/chatmainwindow.ui.h6
-rw-r--r--tests/auto/tools/uic/baseline/mydialog.ui.h4
-rw-r--r--tests/auto/tools/uic/baseline/trpreviewtool.ui.h4
-rw-r--r--tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp24
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp2
-rw-r--r--tests/manual/manual.pro3
-rw-r--r--tests/manual/qtabbar/main.cpp153
-rw-r--r--tests/manual/qtabbar/qtabbar.pro4
14 files changed, 343 insertions, 32 deletions
diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
index 3f3533c9a1..03c28f4d0b 100644
--- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
@@ -1026,7 +1026,7 @@ void tst_QProcess::softExitInSlots()
SoftExitProcess proc(signalToConnect);
proc.writeAfterStart("OLEBOLE", 8); // include the \0
proc.start(appName);
- QTRY_VERIFY_WITH_TIMEOUT(proc.waitedForFinished, 10000);
+ QTRY_VERIFY_WITH_TIMEOUT(proc.waitedForFinished, 60000);
QCOMPARE(proc.state(), QProcess::NotRunning);
}
diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
index d57c4629cc..78833d08bd 100644
--- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
+++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
@@ -379,6 +379,8 @@ void tst_QMetaType::typeName_data()
QT_FOR_EACH_STATIC_TYPE(TYPENAME_DATA)
QTest::newRow("QMetaType::UnknownType") << int(QMetaType::UnknownType) << static_cast<const char*>(0);
+ QTest::newRow("QMetaType::User-1") << (int(QMetaType::User) - 1) << static_cast<const char *>(nullptr);
+ QTest::newRow("QMetaType::FirstWidgetsType-1") << (int(QMetaType::FirstWidgetsType) - 1) << static_cast<const char *>(nullptr);
QTest::newRow("Whity<double>") << ::qMetaTypeId<Whity<double> >() << QString::fromLatin1("Whity<double>");
QTest::newRow("Whity<int>") << ::qMetaTypeId<Whity<int> >() << QString::fromLatin1("Whity<int>");
@@ -407,10 +409,12 @@ void tst_QMetaType::typeName()
QFETCH(int, aType);
QFETCH(QString, aTypeName);
- QString name = QString::fromLatin1(QMetaType::typeName(aType));
+ const char *rawname = QMetaType::typeName(aType);
+ QString name = QString::fromLatin1(rawname);
QCOMPARE(name, aTypeName);
QCOMPARE(name.toLatin1(), QMetaObject::normalizedType(name.toLatin1().constData()));
+ QCOMPARE(rawname == nullptr, aTypeName.isNull());
}
void tst_QMetaType::type_data()
diff --git a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp
index bd02dc6255..18649b3de5 100644
--- a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp
+++ b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp
@@ -133,6 +133,9 @@ private slots:
void gifImageCount();
void gifLoopCount();
+ void ppmMaxval_data();
+ void ppmMaxval();
+
void readCorruptImage_data();
void readCorruptImage();
void readCorruptBmp();
@@ -956,6 +959,79 @@ void tst_QImageReader::gifLoopCount()
}
}
+void tst_QImageReader::ppmMaxval_data()
+{
+ QTest::addColumn<bool>("hasColor");
+ QTest::addColumn<QByteArray>("bytes");
+
+ QTest::newRow("PGM plain 8bit full") << false << QByteArray("P2 3 1 255 255 0 127\n");
+ QTest::newRow("PGM plain 8bit lim.") << false << QByteArray("P2 3 1 50 50 0 25\n");
+ QTest::newRow("PGM plain 16bit full") << false << QByteArray("P2 3 1 65535 65535 0 32767\n");
+ QTest::newRow("PGM plain 16bit lim.") << false << QByteArray("P2 3 1 5000 5000 0 2500\n");
+ QTest::newRow("PGM raw 8bit full") << false << QByteArray("P5 3 1 255 \xff\x00\x7f", 13 + 3);
+ QTest::newRow("PGM raw 8bit lim.") << false << QByteArray("P5 3 1 50 \x32\x00\x19", 13 + 3);
+ QTest::newRow("PGM raw 16bit full") << false << QByteArray("P5 3 1 65535 \xff\xff\x00\x00\x7f\xff", 13 + 3 * 2);
+ QTest::newRow("PGM raw 16bit lim.") << false << QByteArray("P5 3 1 5000 \x13\x88\x00\x00\x09\xc4", 13 + 3 * 2);
+
+ QTest::newRow("PPM plain 8bit full") << true << QByteArray("P3 3 2 255 "
+ "255 255 255 0 0 0 127 127 127 "
+ "255 0 0 0 255 0 0 0 255\n");
+
+ QTest::newRow("PPM plain 8bit lim.") << true << QByteArray("P3 3 2 50 "
+ " 50 50 50 0 0 0 25 25 25 "
+ " 50 0 0 0 50 0 0 0 50\n");
+
+ QTest::newRow("PPM plain 16bit full") << true << QByteArray("P3 3 2 65535 "
+ "65535 65535 65535 0 0 0 32767 32767 32767 "
+ "65535 0 0 0 65535 0 0 0 65535\n");
+
+ QTest::newRow("PPM plain 16bit lim.") << true << QByteArray("P3 3 2 5000 "
+ " 5000 5000 5000 0 0 0 2500 2500 2500 "
+ " 5000 0 0 0 5000 0 0 0 5000\n");
+
+ QTest::newRow("PPM raw 8bit full") << true << QByteArray("P6 3 2 255 "
+ "\xff\xff\xff\x00\x00\x00\x7f\x7f\x7f"
+ "\xff\x00\x00\x00\xff\x00\x00\x00\xff", 13 + 6 * 3);
+
+ QTest::newRow("PPM raw 8bit lim.") << true << QByteArray("P6 3 2 50 "
+ "\x32\x32\x32\x00\x00\x00\x19\x19\x19"
+ "\x32\x00\x00\x00\x32\x00\x00\x00\x32", 13 + 6 * 3);
+
+ QTest::newRow("PPM raw 16bit full") << true << QByteArray("P6 3 2 65535 "
+ "\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x7f\xff\x7f\xff\x7f\xff"
+ "\xff\xff\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00\x00\x00\x00\x00\xff\xff", 13 + 6 * 3 * 2);
+
+ QTest::newRow("PPM raw 16bit lim.") << true << QByteArray("P6 3 2 5000 "
+ "\x13\x88\x13\x88\x13\x88\x00\x00\x00\x00\x00\x00\x09\xc4\x09\xc4\x09\xc4"
+ "\x13\x88\x00\x00\x00\x00\x00\x00\x13\x88\x00\x00\x00\x00\x00\x00\x13\x88", 13 + 6 * 3 * 2);
+}
+
+void tst_QImageReader::ppmMaxval()
+{
+ SKIP_IF_UNSUPPORTED("ppm");
+
+ QFETCH(bool, hasColor);
+ QFETCH(QByteArray, bytes);
+
+ QImage img;
+ img.loadFromData(bytes);
+ QVERIFY(!img.isNull());
+ QCOMPARE(img.width(), 3);
+ QCOMPARE(img.height(), hasColor ? 2 : 1);
+
+ QCOMPARE(img.pixel(0,0), qRgb(0xff, 0xff, 0xff));
+ QCOMPARE(img.pixel(1,0), qRgb(0, 0, 0));
+ QRgb gray = img.pixel(2,0);
+ QVERIFY(qIsGray(gray));
+ QVERIFY(qRed(gray) > 0x70 && qRed(gray) < 0x90 );
+
+ if (hasColor) {
+ QCOMPARE(img.pixel(0,1), qRgb(0xff, 0, 0));
+ QCOMPARE(img.pixel(1,1), qRgb(0, 0xff, 0));
+ QCOMPARE(img.pixel(2,1), qRgb(0, 0, 0xff));
+ }
+}
+
class Server : public QObject
{
Q_OBJECT
diff --git a/tests/auto/tools/moc/cxx17-namespaces.h b/tests/auto/tools/moc/cxx17-namespaces.h
new file mode 100644
index 0000000000..7c9f54d5f3
--- /dev/null
+++ b/tests/auto/tools/moc/cxx17-namespaces.h
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Olivier Goffart.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef CXX17_NAMESPACES_H
+#define CXX11_NAMESPACES_H
+#include <QtCore/QObject>
+
+#if defined(__cpp_nested_namespace_definitions) || defined(Q_MOC_RUN)
+namespace CXX17Namespace::A::B {
+namespace C::D {
+namespace E::F::G { } // don't confuse moc
+#else
+namespace CXX17Namespace { namespace A { namespace B {
+namespace C { namespace D {
+#endif
+
+Q_NAMESPACE
+
+class ClassInNamespace
+{
+ Q_GADGET
+public:
+ enum GadEn { Value = 3 };
+ Q_ENUM(GadEn)
+};
+
+enum NamEn { Value = 4 };
+Q_ENUM_NS(NamEn);
+
+
+#if defined(__cpp_nested_namespace_definitions) || defined(Q_MOC_RUN)
+}
+}
+#else
+} } }
+} }
+#endif
+
+#endif
diff --git a/tests/auto/tools/moc/moc.pro b/tests/auto/tools/moc/moc.pro
index d2b750bdc5..b7151f9c16 100644
--- a/tests/auto/tools/moc/moc.pro
+++ b/tests/auto/tools/moc/moc.pro
@@ -29,7 +29,7 @@ HEADERS += using-namespaces.h no-keywords.h task87883.h c-comments.h backslash-n
non-gadget-parent-class.h grand-parent-gadget-class.h \
related-metaobjects-in-gadget.h \
related-metaobjects-name-conflict.h \
- namespace.h
+ namespace.h cxx17-namespaces.h
if(*-g++*|*-icc*|*-clang*|*-llvm):!irix-*:!win32-*: HEADERS += os9-newlines.h win-newlines.h
diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp
index e704a6877e..2d7ec2f0b5 100644
--- a/tests/auto/tools/moc/tst_moc.cpp
+++ b/tests/auto/tools/moc/tst_moc.cpp
@@ -70,6 +70,7 @@
#include "non-gadget-parent-class.h"
#include "grand-parent-gadget-class.h"
#include "namespace.h"
+#include "cxx17-namespaces.h"
#ifdef Q_MOC_RUN
// check that moc can parse these constructs, they are being used in Windows winsock2.h header
@@ -521,6 +522,10 @@ public slots:
private:
myNS::Points m_points;
+#ifdef Q_MOC_RUN
+ int xx = 11'11; // digit separator must not confuse moc (QTBUG-59351)
+#endif
+
private slots:
inline virtual void blub1() {}
virtual inline void blub2() {}
@@ -696,6 +701,7 @@ private slots:
void optionsFileError_data();
void optionsFileError();
void testQNamespace();
+ void cxx17Namespaces();
signals:
void sigWithUnsignedArg(unsigned foo);
@@ -3799,6 +3805,25 @@ void tst_Moc::testQNamespace()
QCOMPARE(FooNamespace::FooNestedNamespace::FooMoreNestedNamespace::staticMetaObject.enumeratorCount(), 1);
}
+void tst_Moc::cxx17Namespaces()
+{
+ QCOMPARE(CXX17Namespace::A::B::C::D::staticMetaObject.className(),
+ "CXX17Namespace::A::B::C::D");
+ QCOMPARE(CXX17Namespace::A::B::C::D::staticMetaObject.enumeratorCount(), 1);
+ QCOMPARE(CXX17Namespace::A::B::C::D::staticMetaObject.enumerator(0).name(), "NamEn");
+ QCOMPARE(QMetaEnum::fromType<CXX17Namespace::A::B::C::D::NamEn>().name(), "NamEn");
+ QCOMPARE(QMetaEnum::fromType<CXX17Namespace::A::B::C::D::NamEn>().keyCount(), 1);
+ QCOMPARE(QMetaEnum::fromType<CXX17Namespace::A::B::C::D::NamEn>().value(0), 4);
+
+ QCOMPARE(CXX17Namespace::A::B::C::D::ClassInNamespace::staticMetaObject.className(),
+ "CXX17Namespace::A::B::C::D::ClassInNamespace");
+ QCOMPARE(CXX17Namespace::A::B::C::D::ClassInNamespace::staticMetaObject.enumeratorCount(), 1);
+ QCOMPARE(CXX17Namespace::A::B::C::D::ClassInNamespace::staticMetaObject.enumerator(0).name(), "GadEn");
+ QCOMPARE(QMetaEnum::fromType<CXX17Namespace::A::B::C::D::ClassInNamespace::GadEn>().name(), "GadEn");
+ QCOMPARE(QMetaEnum::fromType<CXX17Namespace::A::B::C::D::ClassInNamespace::GadEn>().keyCount(), 1);
+ QCOMPARE(QMetaEnum::fromType<CXX17Namespace::A::B::C::D::ClassInNamespace::GadEn>().value(0), 3);
+}
+
QTEST_MAIN(tst_Moc)
// the generated code must compile with QT_NO_KEYWORDS
diff --git a/tests/auto/tools/uic/baseline/chatmainwindow.ui.h b/tests/auto/tools/uic/baseline/chatmainwindow.ui.h
index 8cfd9b4851..7f8b026ba5 100644
--- a/tests/auto/tools/uic/baseline/chatmainwindow.ui.h
+++ b/tests/auto/tools/uic/baseline/chatmainwindow.ui.h
@@ -1,7 +1,7 @@
/********************************************************************************
** Form generated from reading UI file 'chatmainwindow.ui'
**
-** Created by: Qt User Interface Compiler version 5.0.0
+** Created by: Qt User Interface Compiler version 5.9.0
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
@@ -151,10 +151,14 @@ public:
{
ChatMainWindow->setWindowTitle(QApplication::translate("ChatMainWindow", "Qt D-Bus Chat", Q_NULLPTR));
actionQuit->setText(QApplication::translate("ChatMainWindow", "Quit", Q_NULLPTR));
+#ifndef QT_NO_SHORTCUT
actionQuit->setShortcut(QApplication::translate("ChatMainWindow", "Ctrl+Q", Q_NULLPTR));
+#endif // QT_NO_SHORTCUT
actionAboutQt->setText(QApplication::translate("ChatMainWindow", "About Qt...", Q_NULLPTR));
actionChangeNickname->setText(QApplication::translate("ChatMainWindow", "Change nickname...", Q_NULLPTR));
+#ifndef QT_NO_SHORTCUT
actionChangeNickname->setShortcut(QApplication::translate("ChatMainWindow", "Ctrl+N", Q_NULLPTR));
+#endif // QT_NO_SHORTCUT
#ifndef QT_NO_TOOLTIP
chatHistory->setToolTip(QApplication::translate("ChatMainWindow", "Messages sent and received from other users", Q_NULLPTR));
#endif // QT_NO_TOOLTIP
diff --git a/tests/auto/tools/uic/baseline/mydialog.ui.h b/tests/auto/tools/uic/baseline/mydialog.ui.h
index 061b476f63..279dd0e9bf 100644
--- a/tests/auto/tools/uic/baseline/mydialog.ui.h
+++ b/tests/auto/tools/uic/baseline/mydialog.ui.h
@@ -1,7 +1,7 @@
/********************************************************************************
** Form generated from reading UI file 'mydialog.ui'
**
-** Created by: Qt User Interface Compiler version 5.0.0
+** Created by: Qt User Interface Compiler version 5.9.0
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
@@ -62,7 +62,9 @@ public:
MyDialog->setWindowTitle(QApplication::translate("MyDialog", "Mach 2!", Q_NULLPTR));
aLabel->setText(QApplication::translate("MyDialog", "Join the life in the fastlane; - PCH enable your project today! -", Q_NULLPTR));
aButton->setText(QApplication::translate("MyDialog", "&Quit", Q_NULLPTR));
+#ifndef QT_NO_SHORTCUT
aButton->setShortcut(QApplication::translate("MyDialog", "Alt+Q", Q_NULLPTR));
+#endif // QT_NO_SHORTCUT
} // retranslateUi
};
diff --git a/tests/auto/tools/uic/baseline/trpreviewtool.ui.h b/tests/auto/tools/uic/baseline/trpreviewtool.ui.h
index d694ae5a8d..7545b4c803 100644
--- a/tests/auto/tools/uic/baseline/trpreviewtool.ui.h
+++ b/tests/auto/tools/uic/baseline/trpreviewtool.ui.h
@@ -31,7 +31,7 @@
/********************************************************************************
** Form generated from reading UI file 'trpreviewtool.ui'
**
-** Created by: Qt User Interface Compiler version 5.0.0
+** Created by: Qt User Interface Compiler version 5.9.0
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
@@ -168,7 +168,9 @@ public:
actionOpenForm->setText(QApplication::translate("TrPreviewToolClass", "&Open Form...", Q_NULLPTR));
actionLoadTranslation->setText(QApplication::translate("TrPreviewToolClass", "&Load Translation...", Q_NULLPTR));
actionReloadTranslations->setText(QApplication::translate("TrPreviewToolClass", "&Reload Translations", Q_NULLPTR));
+#ifndef QT_NO_SHORTCUT
actionReloadTranslations->setShortcut(QApplication::translate("TrPreviewToolClass", "F5", Q_NULLPTR));
+#endif // QT_NO_SHORTCUT
actionClose->setText(QApplication::translate("TrPreviewToolClass", "&Close", Q_NULLPTR));
actionAbout->setText(QApplication::translate("TrPreviewToolClass", "About", Q_NULLPTR));
actionAbout_Qt->setText(QApplication::translate("TrPreviewToolClass", "About Qt", Q_NULLPTR));
diff --git a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
index 29e4bbfe29..a89f8f3c8a 100644
--- a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
+++ b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
@@ -150,7 +150,6 @@ private slots:
void horizontalScrollingByVerticalWheelEvents();
void taskQTBUG_7232_AllowUserToControlSingleStep();
void taskQTBUG_51086_skippingIndexesInSelectedIndexes();
- void expandingListItems();
void taskQTBUG_47694_indexOutOfBoundBatchLayout();
};
@@ -2488,29 +2487,6 @@ void tst_QListView::taskQTBUG_51086_skippingIndexesInSelectedIndexes()
QVERIFY(!indexes.contains(data.index(8, 0)));
}
-void tst_QListView::expandingListItems()
-{
- auto item1 = new QStandardItem("111");
- auto item2 = new QStandardItem("111111");
- QStandardItemModel model;
- model.appendRow(item1);
- model.appendRow(item2);
-
- QListView w;
- w.setModel(&model);
- w.setWrapping(true);
- w.show();
- QVERIFY(QTest::qWaitForWindowExposed(&w));
-
- QVERIFY(w.visualRect(item1->index()).width() > 0);
- QVERIFY(w.visualRect(item1->index()).width() == w.visualRect(item2->index()).width());
-
- w.setExpandingListItems(false);
- QApplication::processEvents();
-
- QVERIFY(w.visualRect(item1->index()).width() < w.visualRect(item2->index()).width());
-}
-
void tst_QListView::taskQTBUG_47694_indexOutOfBoundBatchLayout()
{
QListView view;
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index 7afa7ca42b..5715505fd6 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -8181,7 +8181,7 @@ void tst_QWidget::customDpi()
custom->logicalDpiX();
QCOMPARE(custom->metricCallCount, 1);
child->logicalDpiX();
- QCOMPARE(custom->metricCallCount, 2);
+ QCOMPARE(custom->metricCallCount, 1);
}
void tst_QWidget::customDpiProperty()
diff --git a/tests/manual/manual.pro b/tests/manual/manual.pro
index a93a003dff..a9d27fa488 100644
--- a/tests/manual/manual.pro
+++ b/tests/manual/manual.pro
@@ -52,7 +52,8 @@ xembed-widgets \
shortcuts \
dialogs \
windowtransparency \
-unc
+unc \
+qtabbar
!qtConfig(openssl): SUBDIRS -= qssloptions
diff --git a/tests/manual/qtabbar/main.cpp b/tests/manual/qtabbar/main.cpp
new file mode 100644
index 0000000000..b1ef0df100
--- /dev/null
+++ b/tests/manual/qtabbar/main.cpp
@@ -0,0 +1,153 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QWidget>
+#include <QStackedWidget>
+#include <QTabBar>
+#include <QLabel>
+#include <QLayout>
+#include <QDesktopWidget>
+#include <QTabWidget>
+
+const int TabCount = 5;
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ QWidget widget;
+ QStackedWidget stackedWidget;
+ QTabBar tabBar;
+ tabBar.setDocumentMode(true);
+ tabBar.setTabsClosable(true);
+ tabBar.setMovable(true);
+ tabBar.setExpanding(true);
+
+ // top
+ tabBar.setShape(QTabBar::RoundedNorth);
+ // bottom
+// tabBar.setShape(QTabBar::RoundedSouth);
+ // left
+// tabBar.setShape(QTabBar::RoundedWest);
+ // right
+// tabBar.setShape(QTabBar::RoundedEast);
+
+ QMap<int, QWidget*> tabs;
+ for (int i = 0; i < TabCount; i++) {
+ QString tabNumberString = QString::number(i);
+ QLabel *label = new QLabel(QStringLiteral("Tab %1 content").arg(tabNumberString));
+ tabs[i] = label;
+ label->setAlignment(Qt::AlignCenter);
+ stackedWidget.addWidget(label);
+ tabBar.addTab(QStringLiteral("Tab %1").arg(tabNumberString));
+ }
+
+ QObject::connect(&tabBar, &QTabBar::tabMoved, [&tabs](int from, int to) {
+ QWidget *thisWidget = tabs[from];
+ QWidget *thatWidget = tabs[to];
+ tabs[from] = thatWidget;
+ tabs[to] = thisWidget;
+ });
+
+ QObject::connect(&tabBar, &QTabBar::currentChanged, [&stackedWidget, &tabs](int index) {
+ if (index >= 0)
+ stackedWidget.setCurrentWidget(tabs[index]);
+ });
+
+ QObject::connect(&tabBar, &QTabBar::tabCloseRequested, [&stackedWidget, &tabBar, &tabs](int index) {
+ QWidget *widget = tabs[index];
+ tabBar.removeTab(index);
+ for (int i = index + 1; i < TabCount; i++)
+ tabs[i-1] = tabs[i];
+ int currentIndex = tabBar.currentIndex();
+ if (currentIndex >= 0)
+ stackedWidget.setCurrentWidget(tabs[currentIndex]);
+ delete widget;
+ });
+
+ QLayout *layout;
+ switch (tabBar.shape()) {
+ case QTabBar::RoundedEast:
+ case QTabBar::TriangularEast:
+ tabBar.setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding);
+ layout = new QHBoxLayout(&widget);
+ layout->addWidget(&stackedWidget);
+ layout->addWidget(&tabBar);
+ break;
+ case QTabBar::RoundedWest:
+ case QTabBar::TriangularWest:
+ tabBar.setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding);
+ layout = new QHBoxLayout(&widget);
+ layout->addWidget(&tabBar);
+ layout->addWidget(&stackedWidget);
+ break;
+ case QTabBar::RoundedNorth:
+ case QTabBar::TriangularNorth:
+ tabBar.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
+ layout = new QVBoxLayout(&widget);
+ layout->addWidget(&tabBar);
+ layout->addWidget(&stackedWidget);
+ break;
+ case QTabBar::RoundedSouth:
+ case QTabBar::TriangularSouth:
+ tabBar.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
+ layout = new QVBoxLayout(&widget);
+ layout->addWidget(&stackedWidget);
+ layout->addWidget(&tabBar);
+ break;
+ }
+
+ layout->setMargin(0);
+ widget.resize(QApplication::desktop()->screenGeometry(&widget).size() * 0.5);
+ widget.show();
+
+ return app.exec();
+}
diff --git a/tests/manual/qtabbar/qtabbar.pro b/tests/manual/qtabbar/qtabbar.pro
new file mode 100644
index 0000000000..a63da72158
--- /dev/null
+++ b/tests/manual/qtabbar/qtabbar.pro
@@ -0,0 +1,4 @@
+TARGET = qtabbar
+TEMPLATE = app
+QT = core gui widgets
+SOURCES = main.cpp