summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/widgets')
-rw-r--r--tests/auto/widgets/dialogs/CMakeLists.txt3
-rw-r--r--tests/auto/widgets/dialogs/dialogs.pro3
-rw-r--r--tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp10
-rw-r--r--tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp4
-rw-r--r--tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp6
-rw-r--r--tests/auto/widgets/dialogs/qfilesystemmodel/.gitignore1
-rw-r--r--tests/auto/widgets/dialogs/qfilesystemmodel/BLACKLIST5
-rw-r--r--tests/auto/widgets/dialogs/qfilesystemmodel/CMakeLists.txt27
-rw-r--r--tests/auto/widgets/dialogs/qfilesystemmodel/qfilesystemmodel.pro13
-rw-r--r--tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp1207
-rw-r--r--tests/auto/widgets/dialogs/qinputdialog/tst_qinputdialog.cpp2
-rw-r--r--tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp3
-rw-r--r--tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp24
-rw-r--r--tests/auto/widgets/dialogs/qsidebar/tst_qsidebar.cpp10
-rw-r--r--tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp24
-rw-r--r--tests/auto/widgets/dialogs/qwizard/tst_qwizard_2.cpp2
-rw-r--r--tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp18
-rw-r--r--tests/auto/widgets/effects/qpixmapfilter/tst_qpixmapfilter.cpp11
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp6
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp2
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicseffectsource/tst_qgraphicseffectsource.cpp14
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp4
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp12
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp42
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicslayoutitem/tst_qgraphicslayoutitem.cpp6
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp7
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsobject/tst_qgraphicsobject.cpp8
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp2
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsscene/.prev_CMakeLists.txt77
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsscene/CMakeLists.txt1
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsscene/qgraphicsscene.pro2
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp47
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicssceneindex/tst_qgraphicssceneindex.cpp12
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicstransform/tst_qgraphicstransform.cpp2
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp79
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.h4
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview_2.cpp2
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp66
-rw-r--r--tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp8
-rw-r--r--tests/auto/widgets/itemviews/qcolumnview/BLACKLIST3
-rw-r--r--tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp9
-rw-r--r--tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp26
-rw-r--r--tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp7
-rw-r--r--tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp66
-rw-r--r--tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp35
-rw-r--r--tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp5
-rw-r--r--tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp28
-rw-r--r--tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp18
-rw-r--r--tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp8
-rw-r--r--tests/auto/widgets/kernel/qgesturerecognizer/tst_qgesturerecognizer.cpp12
-rw-r--r--tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp16
-rw-r--r--tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp18
-rw-r--r--tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp106
-rw-r--r--tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp16
-rw-r--r--tests/auto/widgets/kernel/qstackedlayout/tst_qstackedlayout.cpp4
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp50
-rw-r--r--tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp28
-rw-r--r--tests/auto/widgets/kernel/qwidgetaction/tst_qwidgetaction.cpp4
-rw-r--r--tests/auto/widgets/kernel/qwidgetmetatype/tst_qwidgetmetatype.cpp20
-rw-r--r--tests/auto/widgets/kernel/qwidgetsvariant/tst_qwidgetsvariant.cpp26
-rw-r--r--tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp3
-rw-r--r--tests/auto/widgets/styles/qmacstyle/tst_qmacstyle.cpp1
-rw-r--r--tests/auto/widgets/styles/qstyle/tst_qstyle.cpp4
-rw-r--r--tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp19
-rw-r--r--tests/auto/widgets/util/qscroller/tst_qscroller.cpp2
-rw-r--r--tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp6
-rw-r--r--tests/auto/widgets/widgets/qabstractscrollarea/tst_qabstractscrollarea.cpp2
-rw-r--r--tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp2
-rw-r--r--tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp50
-rw-r--r--tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp6
-rw-r--r--tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp12
-rw-r--r--tests/auto/widgets/widgets/qfocusframe/tst_qfocusframe.cpp2
-rw-r--r--tests/auto/widgets/widgets/qframe/.prev_CMakeLists.txt20
-rw-r--r--tests/auto/widgets/widgets/qframe/CMakeLists.txt1
-rw-r--r--tests/auto/widgets/widgets/qframe/qframe.pro2
-rw-r--r--tests/auto/widgets/widgets/qframe/tst_qframe.cpp3
-rw-r--r--tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp6
-rw-r--r--tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp2
-rw-r--r--tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp14
-rw-r--r--tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp6
-rw-r--r--tests/auto/widgets/widgets/qmdiarea/BLACKLIST1
-rw-r--r--tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp8
-rw-r--r--tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp2
-rw-r--r--tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp4
-rw-r--r--tests/auto/widgets/widgets/qmenubar/BLACKLIST1
-rw-r--r--tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp2
-rw-r--r--tests/auto/widgets/widgets/qopenglwidget/.prev_CMakeLists.txt18
-rw-r--r--tests/auto/widgets/widgets/qopenglwidget/CMakeLists.txt1
-rw-r--r--tests/auto/widgets/widgets/qopenglwidget/qopenglwidget.pro2
-rw-r--r--tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp5
-rw-r--r--tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp26
-rw-r--r--tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp2
-rw-r--r--tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp12
-rw-r--r--tests/auto/widgets/widgets/qscrollarea/tst_qscrollarea.cpp4
-rw-r--r--tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp4
-rw-r--r--tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp17
-rw-r--r--tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp4
-rw-r--r--tests/auto/widgets/widgets/qstackedwidget/tst_qstackedwidget.cpp4
-rw-r--r--tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp2
-rw-r--r--tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp9
-rw-r--r--tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp3
-rw-r--r--tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp33
-rw-r--r--tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp31
103 files changed, 829 insertions, 1810 deletions
diff --git a/tests/auto/widgets/dialogs/CMakeLists.txt b/tests/auto/widgets/dialogs/CMakeLists.txt
index 0c52076efe..13c4e6cad8 100644
--- a/tests/auto/widgets/dialogs/CMakeLists.txt
+++ b/tests/auto/widgets/dialogs/CMakeLists.txt
@@ -10,9 +10,6 @@ add_subdirectory(qinputdialog)
add_subdirectory(qmessagebox)
add_subdirectory(qprogressdialog)
add_subdirectory(qwizard)
-if(NOT MINGW)
- add_subdirectory(qfilesystemmodel)
-endif()
if(QT_FEATURE_private_tests)
add_subdirectory(qsidebar)
endif()
diff --git a/tests/auto/widgets/dialogs/dialogs.pro b/tests/auto/widgets/dialogs/dialogs.pro
index cf548f2dea..b4217a219d 100644
--- a/tests/auto/widgets/dialogs/dialogs.pro
+++ b/tests/auto/widgets/dialogs/dialogs.pro
@@ -5,7 +5,6 @@ SUBDIRS=\
qerrormessage \
qfiledialog \
qfiledialog2 \
- qfilesystemmodel \
qfontdialog \
qinputdialog \
qmessagebox \
@@ -17,4 +16,4 @@ SUBDIRS=\
qsidebar \
mac:qinputdialog.CONFIG += no_check_target # QTBUG-25496
-mingw: SUBDIRS -= qfilesystemmodel # QTBUG-29403
+
diff --git a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp
index fa374ee076..266ed0de05 100644
--- a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp
+++ b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp
@@ -104,12 +104,14 @@ public:
bool wasActive() const { return mWasActive; }
bool wasModalWindow() const { return mWasModalWindow; }
- int exec() {
+ int exec() override
+ {
tId = startTimer(300);
return QDialog::exec();
}
protected:
- void timerEvent(QTimerEvent *event) {
+ void timerEvent(QTimerEvent *event) override
+ {
if (tId == event->timerId()) {
killTimer(tId);
mWasActive = isActiveWindow();
@@ -321,7 +323,7 @@ void tst_QDialog::toolDialogPosition()
dialog.move(QPoint(100,100));
const QPoint beforeShowPosition = dialog.pos();
dialog.show();
- const int fuzz = int(dialog.devicePixelRatioF());
+ const int fuzz = int(dialog.devicePixelRatio());
const QPoint afterShowPosition = dialog.pos();
QVERIFY2(HighDpi::fuzzyCompare(afterShowPosition, beforeShowPosition, fuzz),
HighDpi::msgPointMismatch(afterShowPosition, beforeShowPosition).constData());
@@ -414,7 +416,7 @@ class TestRejectDialog : public QDialog
{
public:
TestRejectDialog() : cancelReject(false), called(0) {}
- void reject()
+ void reject() override
{
called++;
if (!cancelReject)
diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
index 20c0dd993b..4b9466d3b6 100644
--- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
+++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
@@ -201,8 +201,8 @@ class MyAbstractItemDelegate : public QAbstractItemDelegate
{
public:
MyAbstractItemDelegate() : QAbstractItemDelegate() {};
- void paint(QPainter *, const QStyleOptionViewItem &, const QModelIndex &) const {}
- QSize sizeHint(const QStyleOptionViewItem &, const QModelIndex &) const { return QSize(); }
+ void paint(QPainter *, const QStyleOptionViewItem &, const QModelIndex &) const override {}
+ QSize sizeHint(const QStyleOptionViewItem &, const QModelIndex &) const override { return QSize(); }
};
// emitted any time the selection model emits current changed
diff --git a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
index e6130c56b1..beec8db0d9 100644
--- a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
+++ b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
@@ -49,7 +49,7 @@
#include <qmenu.h>
#include <qrandom.h>
#include "../../../../../src/widgets/dialogs/qsidebar_p.h"
-#include "../../../../../src/widgets/dialogs/qfilesystemmodel_p.h"
+#include "../../../../../src/gui/itemmodels/qfilesystemmodel_p.h"
#include "../../../../../src/widgets/dialogs/qfiledialog_p.h"
#include <private/qguiapplication_p.h>
@@ -482,7 +482,7 @@ public:
{};
protected:
- bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const
+ bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override
{
QModelIndex parentIndex;
parentIndex = source_parent;
@@ -515,7 +515,7 @@ public:
{
}
protected:
- virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const
+ virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const override
{
QFileSystemModel * const model = qobject_cast<QFileSystemModel *>(sourceModel());
const QFileInfo leftInfo(model->fileInfo(left));
diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/.gitignore b/tests/auto/widgets/dialogs/qfilesystemmodel/.gitignore
deleted file mode 100644
index 9804e5a3d7..0000000000
--- a/tests/auto/widgets/dialogs/qfilesystemmodel/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-tst_qfilesystemmodel
diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/BLACKLIST b/tests/auto/widgets/dialogs/qfilesystemmodel/BLACKLIST
deleted file mode 100644
index 4119afce84..0000000000
--- a/tests/auto/widgets/dialogs/qfilesystemmodel/BLACKLIST
+++ /dev/null
@@ -1,5 +0,0 @@
-[sort:QFileDialog usage]
-ubuntu
-b2qt
-[specialFiles]
-b2qt
diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/CMakeLists.txt b/tests/auto/widgets/dialogs/qfilesystemmodel/CMakeLists.txt
deleted file mode 100644
index 595b30bd56..0000000000
--- a/tests/auto/widgets/dialogs/qfilesystemmodel/CMakeLists.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-# Generated from qfilesystemmodel.pro.
-
-#####################################################################
-## tst_qfilesystemmodel Test:
-#####################################################################
-
-qt_add_test(tst_qfilesystemmodel
- SOURCES
- ../../../../shared/emulationdetector.h
- tst_qfilesystemmodel.cpp
- INCLUDE_DIRECTORIES
- ../../../../shared
- PUBLIC_LIBRARIES
- Qt::CorePrivate
- Qt::Gui
- Qt::Widgets
- Qt::WidgetsPrivate
-)
-
-## Scopes:
-#####################################################################
-
-#### Keys ignored in scope 2:.:.:qfilesystemmodel.pro:WIN32:
-# testcase.timeout = "900"
-
-#### Keys ignored in scope 3:.:.:qfilesystemmodel.pro:MACOS:
-# testcase.timeout = "900"
diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/qfilesystemmodel.pro b/tests/auto/widgets/dialogs/qfilesystemmodel/qfilesystemmodel.pro
deleted file mode 100644
index db8cf7de3f..0000000000
--- a/tests/auto/widgets/dialogs/qfilesystemmodel/qfilesystemmodel.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-INCLUDEPATH += ../../../../shared
-HEADERS += ../../../../shared/emulationdetector.h
-
-CONFIG += testcase
-# This testcase can be slow on Windows and OS X, and may interfere with other file system tests.
-win32:testcase.timeout = 900
-macx:testcase.timeout = 900
-
-QT += widgets widgets-private
-QT += core-private testlib
-
-SOURCES += tst_qfilesystemmodel.cpp
-TARGET = tst_qfilesystemmodel
diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
deleted file mode 100644
index e814e79dbe..0000000000
--- a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
+++ /dev/null
@@ -1,1207 +0,0 @@
-/****************************************************************************
-**
-** 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: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$
-**
-****************************************************************************/
-
-
-#include <emulationdetector.h>
-#include <QtTest/QtTest>
-#ifdef QT_BUILD_INTERNAL
-#include <private/qfilesystemmodel_p.h>
-#endif
-#include <QFileSystemModel>
-#include <QFileIconProvider>
-#include <QTreeView>
-#include <QHeaderView>
-#include <QStandardPaths>
-#include <QTime>
-#include <QStyle>
-#include <QtGlobal>
-#include <QTemporaryDir>
-#if defined(Q_OS_WIN)
-# include <qt_windows.h> // for SetFileAttributes
-#endif
-#include <private/qfilesystemengine_p.h>
-
-#include <algorithm>
-
-#define WAITTIME 1000
-
-// Will try to wait for the condition while allowing event processing
-// for a maximum of 5 seconds.
-#define TRY_WAIT(expr, timedOut) \
- do { \
- *timedOut = true; \
- const int step = 50; \
- for (int __i = 0; __i < 5000; __i += step) { \
- if (expr) { \
- *timedOut = false; \
- break; \
- } \
- QTest::qWait(step); \
- } \
- } while(0)
-
-Q_DECLARE_METATYPE(QDir::Filters)
-Q_DECLARE_METATYPE(QFileDevice::Permissions)
-
-Q_LOGGING_CATEGORY(lcFileSystemModel, "qt.widgets.tests.qfilesystemmodel")
-
-class tst_QFileSystemModel : public QObject {
- Q_OBJECT
-
-private slots:
- void initTestCase();
- void cleanup();
-
- void indexPath();
-
- void rootPath();
- void readOnly();
- void iconProvider();
-
- void rowCount();
-
- void rowsInserted_data();
- void rowsInserted();
-
- void rowsRemoved_data();
- void rowsRemoved();
-
- void dataChanged_data();
- void dataChanged();
-
- void filters_data();
- void filters();
-
- void nameFilters();
-
- void setData_data();
- void setData();
-
- void sortPersistentIndex();
- void sort_data();
- void sort();
-
- void mkdir();
- void deleteFile();
- void deleteDirectory();
-
- void caseSensitivity();
-
- void drives_data();
- void drives();
- void dirsBeforeFiles();
-
- void roleNames_data();
- void roleNames();
-
- void permissions_data();
- void permissions();
-
- void doNotUnwatchOnFailedRmdir();
- void specialFiles();
-
- void fileInfo();
-
-protected:
- bool createFiles(QFileSystemModel *model, const QString &test_path,
- const QStringList &initial_files, int existingFileCount = 0,
- const QStringList &initial_dirs = QStringList());
- QModelIndex prepareTestModelRoot(QFileSystemModel *model, const QString &test_path,
- QSignalSpy **spy2 = nullptr, QSignalSpy **spy3 = nullptr);
-
-private:
- QString flatDirTestPath;
- QTemporaryDir m_tempDir;
-};
-
-void tst_QFileSystemModel::cleanup()
-{
- QDir dir(flatDirTestPath);
- if (dir.exists()) {
- const QDir::Filters filters = QDir::AllEntries | QDir::System | QDir::Hidden | QDir::NoDotAndDotDot;
- const QFileInfoList list = dir.entryInfoList(filters);
- for (const QFileInfo &fi : list) {
- if (fi.isDir()) {
- QVERIFY(dir.rmdir(fi.fileName()));
- } else {
- QFile dead(fi.absoluteFilePath());
- dead.setPermissions(QFile::ReadUser | QFile::ReadOwner | QFile::ExeOwner | QFile::ExeUser | QFile::WriteUser | QFile::WriteOwner | QFile::WriteOther);
- QVERIFY(dead.remove());
- }
- }
- QVERIFY(dir.entryInfoList(filters).isEmpty());
- }
-}
-
-void tst_QFileSystemModel::initTestCase()
-{
- QVERIFY2(m_tempDir.isValid(), qPrintable(m_tempDir.errorString()));
- flatDirTestPath = m_tempDir.path();
-}
-
-void tst_QFileSystemModel::indexPath()
-{
-#if !defined(Q_OS_WIN)
- QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
- int depth = QDir::currentPath().count('/');
- model->setRootPath(QDir::currentPath());
- QString backPath;
- for (int i = 0; i <= depth * 2 + 1; ++i) {
- backPath += "../";
- QModelIndex idx = model->index(backPath);
- QVERIFY(i != depth - 1 ? idx.isValid() : !idx.isValid());
- }
-#endif
-}
-
-void tst_QFileSystemModel::rootPath()
-{
- QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
- QCOMPARE(model->rootPath(), QString(QDir().path()));
-
- QSignalSpy rootChanged(model.data(), &QFileSystemModel::rootPathChanged);
- QModelIndex root = model->setRootPath(model->rootPath());
- root = model->setRootPath("this directory shouldn't exist");
- QCOMPARE(rootChanged.count(), 0);
-
- QString oldRootPath = model->rootPath();
- const QStringList documentPaths = QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation);
- QVERIFY(!documentPaths.isEmpty());
- QString documentPath = documentPaths.front();
- // In particular on Linux, ~/Documents (the first
- // DocumentsLocation) may not exist, so choose ~ in that case:
- if (!QFile::exists(documentPath)) {
- documentPath = QDir::homePath();
- qWarning("%s: first documentPath \"%s\" does not exist. Using ~ (\"%s\") instead.",
- Q_FUNC_INFO, qPrintable(documentPaths.front()), qPrintable(documentPath));
- }
- root = model->setRootPath(documentPath);
-
- QTRY_VERIFY(model->rowCount(root) >= 0);
- QCOMPARE(model->rootPath(), QString(documentPath));
- QCOMPARE(rootChanged.count(), oldRootPath == model->rootPath() ? 0 : 1);
- QCOMPARE(model->rootDirectory().absolutePath(), documentPath);
-
- model->setRootPath(QDir::rootPath());
- int oldCount = rootChanged.count();
- oldRootPath = model->rootPath();
- root = model->setRootPath(documentPath + QLatin1String("/."));
- QTRY_VERIFY(model->rowCount(root) >= 0);
- QCOMPARE(model->rootPath(), documentPath);
- QCOMPARE(rootChanged.count(), oldRootPath == model->rootPath() ? oldCount : oldCount + 1);
- QCOMPARE(model->rootDirectory().absolutePath(), documentPath);
-
- QDir newdir = documentPath;
- if (newdir.cdUp()) {
- oldCount = rootChanged.count();
- oldRootPath = model->rootPath();
- root = model->setRootPath(documentPath + QLatin1String("/.."));
- QTRY_VERIFY(model->rowCount(root) >= 0);
- QCOMPARE(model->rootPath(), newdir.path());
- QCOMPARE(rootChanged.count(), oldCount + 1);
- QCOMPARE(model->rootDirectory().absolutePath(), newdir.path());
- }
-}
-
-void tst_QFileSystemModel::readOnly()
-{
- QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
- QCOMPARE(model->isReadOnly(), true);
- QTemporaryFile file(flatDirTestPath + QStringLiteral("/XXXXXX.dat"));
- QVERIFY2(file.open(), qPrintable(file.errorString()));
- const QString fileName = file.fileName();
- file.close();
-
- const QFileInfo fileInfo(fileName);
- QTRY_VERIFY(QDir(flatDirTestPath).entryInfoList().contains(fileInfo));
- QModelIndex root = model->setRootPath(flatDirTestPath);
-
- QTRY_VERIFY(model->rowCount(root) > 0);
- QVERIFY(!(model->flags(model->index(fileName)) & Qt::ItemIsEditable));
- model->setReadOnly(false);
- QCOMPARE(model->isReadOnly(), false);
- QVERIFY(model->flags(model->index(fileName)) & Qt::ItemIsEditable);
-}
-
-class CustomFileIconProvider : public QFileIconProvider
-{
-public:
- CustomFileIconProvider() : QFileIconProvider()
- {
- auto style = QApplication::style();
- mb = style->standardIcon(QStyle::SP_MessageBoxCritical);
- dvd = style->standardIcon(QStyle::SP_DriveDVDIcon);
- }
-
- QIcon icon(const QFileInfo &info) const override
- {
- if (info.isDir())
- return mb;
-
- return QFileIconProvider::icon(info);
- }
- QIcon icon(IconType type) const override
- {
- if (type == QFileIconProvider::Folder)
- return dvd;
-
- return QFileIconProvider::icon(type);
- }
-private:
- QIcon mb;
- QIcon dvd;
-};
-
-void tst_QFileSystemModel::iconProvider()
-{
- QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
- QVERIFY(model->iconProvider());
- QScopedPointer<QFileIconProvider> provider(new QFileIconProvider);
- model->setIconProvider(provider.data());
- QCOMPARE(model->iconProvider(), provider.data());
- model->setIconProvider(nullptr);
- provider.reset();
-
- QScopedPointer<QFileSystemModel> myModel(new QFileSystemModel);
- const QStringList documentPaths = QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation);
- QVERIFY(!documentPaths.isEmpty());
- myModel->setRootPath(documentPaths.constFirst());
- //We change the provider, icons must be updated
- provider.reset(new CustomFileIconProvider);
- myModel->setIconProvider(provider.data());
-
- QPixmap mb = QApplication::style()->standardIcon(QStyle::SP_MessageBoxCritical).pixmap(50, 50);
- QCOMPARE(myModel->fileIcon(myModel->index(QDir::homePath())).pixmap(50, 50), mb);
-}
-
-bool tst_QFileSystemModel::createFiles(QFileSystemModel *model, const QString &test_path,
- const QStringList &initial_files, int existingFileCount,
- const QStringList &initial_dirs)
-{
- qCDebug(lcFileSystemModel) << (model->rowCount(model->index(test_path))) << existingFileCount << initial_files;
- bool timedOut = false;
- TRY_WAIT((model->rowCount(model->index(test_path)) == existingFileCount), &timedOut);
- if (timedOut)
- return false;
-
- QDir dir(test_path);
- if (!dir.exists()) {
- qWarning() << "error" << test_path << "doesn't exist";
- return false;
- }
- for (const auto &initial_dir : initial_dirs) {
- if (!dir.mkdir(initial_dir)) {
- qWarning() << "error" << "failed to make" << initial_dir;
- return false;
- }
- qCDebug(lcFileSystemModel) << test_path + '/' + initial_dir << (QFile::exists(test_path + '/' + initial_dir));
- }
- for (const auto &initial_file : initial_files) {
- QFile file(test_path + '/' + initial_file);
- if (!file.open(QIODevice::WriteOnly | QIODevice::Append)) {
- qDebug() << "failed to open file" << initial_file;
- return false;
- }
- if (!file.resize(1024 + file.size())) {
- qDebug() << "failed to resize file" << initial_file;
- return false;
- }
- if (!file.flush()) {
- qDebug() << "failed to flush file" << initial_file;
- return false;
- }
- file.close();
-#if defined(Q_OS_WIN)
- if (initial_file[0] == '.') {
- const QString hiddenFile = QDir::toNativeSeparators(file.fileName());
- const auto nativeHiddenFile = reinterpret_cast<const wchar_t *>(hiddenFile.utf16());
- DWORD currentAttributes = ::GetFileAttributes(nativeHiddenFile);
- if (currentAttributes == 0xFFFFFFFF) {
- qErrnoWarning("failed to get file attributes: %s", qPrintable(hiddenFile));
- return false;
- }
- if (!::SetFileAttributes(nativeHiddenFile, currentAttributes | FILE_ATTRIBUTE_HIDDEN)) {
- qErrnoWarning("failed to set file hidden: %s", qPrintable(hiddenFile));
- return false;
- }
- }
-#endif
- qCDebug(lcFileSystemModel) << test_path + '/' + initial_file << (QFile::exists(test_path + '/' + initial_file));
- }
- return true;
-}
-
-QModelIndex tst_QFileSystemModel::prepareTestModelRoot(QFileSystemModel *model, const QString &test_path,
- QSignalSpy **spy2, QSignalSpy **spy3)
-{
- if (model->rowCount(model->index(test_path)) != 0)
- return QModelIndex();
-
- if (spy2)
- *spy2 = new QSignalSpy(model, &QFileSystemModel::rowsInserted);
- if (spy3)
- *spy3 = new QSignalSpy(model, &QFileSystemModel::rowsAboutToBeInserted);
-
- QStringList files = { "b", "d", "f", "h", "j", ".a", ".c", ".e", ".g" };
-
- if (!createFiles(model, test_path, files))
- return QModelIndex();
-
- QModelIndex root = model->setRootPath(test_path);
- if (!root.isValid())
- return QModelIndex();
-
- bool timedOut = false;
- TRY_WAIT(model->rowCount(root) == 5, &timedOut);
- if (timedOut)
- return QModelIndex();
-
- return root;
-}
-
-void tst_QFileSystemModel::rowCount()
-{
- QSignalSpy *spy2 = nullptr;
- QSignalSpy *spy3 = nullptr;
- QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
- QModelIndex root = prepareTestModelRoot(model.data(), flatDirTestPath, &spy2, &spy3);
- QVERIFY(root.isValid());
-
- QVERIFY(spy2 && spy2->count() > 0);
- QVERIFY(spy3 && spy3->count() > 0);
-}
-
-void tst_QFileSystemModel::rowsInserted_data()
-{
- QTest::addColumn<int>("count");
- QTest::addColumn<Qt::SortOrder>("ascending");
- for (int i = 0; i < 4; ++i) {
- const QByteArray iB = QByteArray::number(i);
- QTest::newRow(("Qt::AscendingOrder " + iB).constData()) << i << Qt::AscendingOrder;
- QTest::newRow(("Qt::DescendingOrder " + iB).constData()) << i << Qt::DescendingOrder;
- }
-}
-
-static inline QString lastEntry(const QModelIndex &root)
-{
- const QAbstractItemModel *model = root.model();
- return model->index(model->rowCount(root) - 1, 0, root).data().toString();
-}
-
-void tst_QFileSystemModel::rowsInserted()
-{
- const QString tmp = flatDirTestPath;
- QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
- QModelIndex root = prepareTestModelRoot(model.data(), tmp);
- QVERIFY(root.isValid());
-
- QFETCH(Qt::SortOrder, ascending);
- QFETCH(int, count);
- model->sort(0, ascending);
-
- QSignalSpy spy0(model.data(), &QAbstractItemModel::rowsInserted);
- QSignalSpy spy1(model.data(), &QAbstractItemModel::rowsAboutToBeInserted);
- int oldCount = model->rowCount(root);
- QStringList files;
- for (int i = 0; i < count; ++i)
- files.append(QLatin1Char('c') + QString::number(i));
- QVERIFY(createFiles(model.data(), tmp, files, 5));
- QTRY_COMPARE(model->rowCount(root), oldCount + count);
- int totalRowsInserted = 0;
- for (int i = 0; i < spy0.count(); ++i) {
- int start = spy0[i].value(1).toInt();
- int end = spy0[i].value(2).toInt();
- totalRowsInserted += end - start + 1;
- }
- QCOMPARE(totalRowsInserted, count);
- const QString expected = ascending == Qt::AscendingOrder ? QStringLiteral("j") : QStringLiteral("b");
- QTRY_COMPARE(lastEntry(root), expected);
-
- if (spy0.count() > 0) {
- if (count == 0)
- QCOMPARE(spy0.count(), 0);
- else
- QVERIFY(spy0.count() >= 1);
- }
- if (count == 0) QCOMPARE(spy1.count(), 0); else QVERIFY(spy1.count() >= 1);
-
- QVERIFY(createFiles(model.data(), tmp, QStringList(".hidden_file"), 5 + count));
-
- if (count != 0)
- QTRY_VERIFY(spy0.count() >= 1);
- else
- QTRY_COMPARE(spy0.count(), 0);
- if (count != 0)
- QTRY_VERIFY(spy1.count() >= 1);
- else
- QTRY_COMPARE(spy1.count(), 0);
-}
-
-void tst_QFileSystemModel::rowsRemoved_data()
-{
- rowsInserted_data();
-}
-
-void tst_QFileSystemModel::rowsRemoved()
-{
- const QString tmp = flatDirTestPath;
- QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
- QModelIndex root = prepareTestModelRoot(model.data(), tmp);
- QVERIFY(root.isValid());
-
- QFETCH(int, count);
- QFETCH(Qt::SortOrder, ascending);
- model->sort(0, ascending);
-
- QSignalSpy spy0(model.data(), &QAbstractItemModel::rowsRemoved);
- QSignalSpy spy1(model.data(), &QAbstractItemModel::rowsAboutToBeRemoved);
- int oldCount = model->rowCount(root);
- for (int i = count - 1; i >= 0; --i) {
- const QString fileName = model->index(i, 0, root).data().toString();
- qCDebug(lcFileSystemModel) << "removing" << fileName;
- QVERIFY(QFile::remove(tmp + QLatin1Char('/') + fileName));
- }
- for (int i = 0 ; i < 10; ++i) {
- if (count != 0) {
- if (i == 10 || spy0.count() != 0) {
- QVERIFY(spy0.count() >= 1);
- QVERIFY(spy1.count() >= 1);
- }
- } else {
- if (i == 10 || spy0.count() == 0) {
- QCOMPARE(spy0.count(), 0);
- QCOMPARE(spy1.count(), 0);
- }
- }
- QStringList lst;
- for (int i = 0; i < model->rowCount(root); ++i)
- lst.append(model->index(i, 0, root).data().toString());
- if (model->rowCount(root) == oldCount - count)
- break;
- qCDebug(lcFileSystemModel) << "still have:" << lst << QFile::exists(tmp + QLatin1String("/.a"));
- QDir tmpLister(tmp);
- qCDebug(lcFileSystemModel) << tmpLister.entryList();
- }
- QTRY_COMPARE(model->rowCount(root), oldCount - count);
-
- QVERIFY(QFile::exists(tmp + QLatin1String("/.a")));
- QVERIFY(QFile::remove(tmp + QLatin1String("/.a")));
- QVERIFY(QFile::remove(tmp + QLatin1String("/.c")));
-
- if (count != 0) {
- QVERIFY(spy0.count() >= 1);
- QVERIFY(spy1.count() >= 1);
- } else {
- QCOMPARE(spy0.count(), 0);
- QCOMPARE(spy1.count(), 0);
- }
-}
-
-void tst_QFileSystemModel::dataChanged_data()
-{
- rowsInserted_data();
-}
-
-void tst_QFileSystemModel::dataChanged()
-{
- QSKIP("This can't be tested right now since we don't watch files, only directories.");
-
- const QString tmp = flatDirTestPath;
- QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
- QModelIndex root = prepareTestModelRoot(model.data(), tmp);
- QVERIFY(root.isValid());
-
- QFETCH(int, count);
- QFETCH(Qt::SortOrder, ascending);
- model->sort(0, ascending);
-
- QSignalSpy spy(model.data(), &QAbstractItemModel::dataChanged);
- QStringList files;
- for (int i = 0; i < count; ++i)
- files.append(model->index(i, 0, root).data().toString());
- createFiles(model.data(), tmp, files);
-
- QTest::qWait(WAITTIME);
-
- if (count != 0) QVERIFY(spy.count() >= 1); else QCOMPARE(spy.count(), 0);
-}
-
-void tst_QFileSystemModel::filters_data()
-{
- QTest::addColumn<QStringList>("files");
- QTest::addColumn<QStringList>("dirs");
- QTest::addColumn<QDir::Filters>("dirFilters");
- QTest::addColumn<QStringList>("nameFilters");
- QTest::addColumn<int>("rowCount");
-
- const QStringList abcList{QLatin1String("a"), QLatin1String("b"), QLatin1String("c")};
- const QStringList zList{QLatin1String("Z")};
-
- QTest::newRow("no dirs") << abcList << QStringList() << QDir::Filters(QDir::Dirs) << QStringList() << 2;
- QTest::newRow("no dirs - dot") << abcList << QStringList() << (QDir::Dirs | QDir::NoDot) << QStringList() << 1;
- QTest::newRow("no dirs - dotdot") << abcList << QStringList() << (QDir::Dirs | QDir::NoDotDot) << QStringList() << 1;
- QTest::newRow("no dirs - dotanddotdot") << abcList << QStringList() << (QDir::Dirs | QDir::NoDotAndDotDot) << QStringList() << 0;
- QTest::newRow("one dir - dot") << abcList << zList << (QDir::Dirs | QDir::NoDot) << QStringList() << 2;
- QTest::newRow("one dir - dotdot") << abcList << zList << (QDir::Dirs | QDir::NoDotDot) << QStringList() << 2;
- QTest::newRow("one dir - dotanddotdot") << abcList << zList << (QDir::Dirs | QDir::NoDotAndDotDot) << QStringList() << 1;
- QTest::newRow("one dir") << abcList << zList << QDir::Filters(QDir::Dirs) << QStringList() << 3;
- QTest::newRow("no dir + hidden") << abcList << QStringList() << (QDir::Dirs | QDir::Hidden) << QStringList() << 2;
- QTest::newRow("dir+hid+files") << abcList << QStringList() <<
- (QDir::Dirs | QDir::Files | QDir::Hidden) << QStringList() << 5;
- QTest::newRow("dir+file+hid-dot .A") << abcList << QStringList{QLatin1String(".A")} <<
- (QDir::Dirs | QDir::Files | QDir::Hidden | QDir::NoDotAndDotDot) << QStringList() << 4;
- QTest::newRow("dir+files+hid+dot A") << abcList << QStringList{QLatin1String("AFolder")} <<
- (QDir::Dirs | QDir::Files | QDir::Hidden | QDir::NoDotAndDotDot) << QStringList{QLatin1String("A*")} << 2;
- QTest::newRow("dir+files+hid+dot+cas1") << abcList << zList <<
- (QDir::Dirs | QDir::Files | QDir::Hidden | QDir::NoDotAndDotDot | QDir::CaseSensitive) << zList << 1;
- QTest::newRow("dir+files+hid+dot+cas2") << abcList << zList <<
- (QDir::Dirs | QDir::Files | QDir::Hidden | QDir::NoDotAndDotDot | QDir::CaseSensitive) << QStringList{QLatin1String("a")} << 1;
- QTest::newRow("dir+files+hid+dot+cas+alldir") << abcList << zList <<
- (QDir::Dirs | QDir::Files | QDir::Hidden | QDir::NoDotAndDotDot | QDir::CaseSensitive | QDir::AllDirs) << zList << 1;
-
- QTest::newRow("case sensitive") << QStringList{QLatin1String("Antiguagdb"), QLatin1String("Antiguamtd"),
- QLatin1String("Antiguamtp"), QLatin1String("afghanistangdb"), QLatin1String("afghanistanmtd")}
- << QStringList() << QDir::Filters(QDir::Files) << QStringList() << 5;
-}
-
-void tst_QFileSystemModel::filters()
-{
- QString tmp = flatDirTestPath;
- QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
- QVERIFY(createFiles(model.data(), tmp, QStringList()));
- QModelIndex root = model->setRootPath(tmp);
- QFETCH(QStringList, files);
- QFETCH(QStringList, dirs);
- QFETCH(QDir::Filters, dirFilters);
- QFETCH(QStringList, nameFilters);
- QFETCH(int, rowCount);
-
- if (nameFilters.count() > 0)
- model->setNameFilters(nameFilters);
- model->setNameFilterDisables(false);
- model->setFilter(dirFilters);
-
- QVERIFY(createFiles(model.data(), tmp, files, 0, dirs));
- QTRY_COMPARE(model->rowCount(root), rowCount);
-
- // Make sure that we do what QDir does
- QDir xFactor(tmp);
- QStringList dirEntries;
-
- if (nameFilters.count() > 0)
- dirEntries = xFactor.entryList(nameFilters, dirFilters);
- else
- dirEntries = xFactor.entryList(dirFilters);
-
- QCOMPARE(dirEntries.count(), rowCount);
-
- QStringList modelEntries;
-
- for (int i = 0; i < rowCount; ++i)
- modelEntries.append(model->data(model->index(i, 0, root), QFileSystemModel::FileNameRole).toString());
-
- std::sort(dirEntries.begin(), dirEntries.end());
- std::sort(modelEntries.begin(), modelEntries.end());
- QCOMPARE(dirEntries, modelEntries);
-
-#ifdef Q_OS_LINUX
- if (files.count() >= 3 && rowCount >= 3 && rowCount != 5) {
- QString fileName1 = (tmp + '/' + files.at(0));
- QString fileName2 = (tmp + '/' + files.at(1));
- QString fileName3 = (tmp + '/' + files.at(2));
- QFile::Permissions originalPermissions = QFile::permissions(fileName1);
- QVERIFY(QFile::setPermissions(fileName1, QFile::WriteOwner));
- QVERIFY(QFile::setPermissions(fileName2, QFile::ReadOwner));
- QVERIFY(QFile::setPermissions(fileName3, QFile::ExeOwner));
-
- model->setFilter((QDir::Files | QDir::Readable));
- QTRY_COMPARE(model->rowCount(root), 1);
-
- model->setFilter((QDir::Files | QDir::Writable));
- QTRY_COMPARE(model->rowCount(root), 1);
-
- model->setFilter((QDir::Files | QDir::Executable));
- QTRY_COMPARE(model->rowCount(root), 1);
-
- // reset permissions
- QVERIFY(QFile::setPermissions(fileName1, originalPermissions));
- QVERIFY(QFile::setPermissions(fileName2, originalPermissions));
- QVERIFY(QFile::setPermissions(fileName3, originalPermissions));
- }
-#endif
-}
-
-void tst_QFileSystemModel::nameFilters()
-{
- QStringList list;
- list << "a" << "b" << "c";
- QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
- model->setNameFilters(list);
- model->setNameFilterDisables(false);
- QCOMPARE(model->nameFilters(), list);
-
- QString tmp = flatDirTestPath;
- QVERIFY(createFiles(model.data(), tmp, list));
- QModelIndex root = model->setRootPath(tmp);
- QTRY_COMPARE(model->rowCount(root), 3);
-
- QStringList filters;
- filters << "a" << "b";
- model->setNameFilters(filters);
- QTRY_COMPARE(model->rowCount(root), 2);
-}
-void tst_QFileSystemModel::setData_data()
-{
- QTest::addColumn<QString>("subdirName");
- QTest::addColumn<QStringList>("files");
- QTest::addColumn<QString>("oldFileName");
- QTest::addColumn<QString>("newFileName");
- QTest::addColumn<bool>("success");
- /*QTest::newRow("outside current dir") << (QStringList() << "a" << "b" << "c")
- << flatDirTestPath + '/' + "a"
- << QDir::temp().absolutePath() + '/' + "a"
- << false;
- */
-
- const QStringList abcList{QLatin1String("a"), QLatin1String("b"), QLatin1String("c")};
- QTest::newRow("in current dir")
- << QString()
- << abcList
- << "a"
- << "d"
- << true;
- QTest::newRow("in subdir")
- << "s"
- << abcList
- << "a"
- << "d"
- << true;
-}
-
-void tst_QFileSystemModel::setData()
-{
- QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
- QSignalSpy spy(model.data(), &QFileSystemModel::fileRenamed);
- QFETCH(QString, subdirName);
- QFETCH(QStringList, files);
- QFETCH(QString, oldFileName);
- QFETCH(QString, newFileName);
- QFETCH(bool, success);
-
- QString tmp = flatDirTestPath;
- if (!subdirName.isEmpty()) {
- QDir dir(tmp);
- QVERIFY(dir.mkdir(subdirName));
- tmp.append('/' + subdirName);
- }
- QVERIFY(createFiles(model.data(), tmp, files));
- QModelIndex tmpIdx = model->setRootPath(flatDirTestPath);
- if (!subdirName.isEmpty()) {
- tmpIdx = model->index(tmp);
- model->fetchMore(tmpIdx);
- }
- QTRY_COMPARE(model->rowCount(tmpIdx), files.count());
-
- QModelIndex idx = model->index(tmp + '/' + oldFileName);
- QCOMPARE(idx.isValid(), true);
- QCOMPARE(model->setData(idx, newFileName), false);
-
- model->setReadOnly(false);
- QCOMPARE(model->setData(idx, newFileName), success);
- model->setReadOnly(true);
- if (success) {
- QCOMPARE(spy.count(), 1);
- QList<QVariant> arguments = spy.takeFirst();
- QCOMPARE(model->data(idx, QFileSystemModel::FileNameRole).toString(), newFileName);
- QCOMPARE(model->fileInfo(idx).filePath(), tmp + '/' + newFileName);
- QCOMPARE(model->index(arguments.at(0).toString()), model->index(tmp));
- QCOMPARE(arguments.at(1).toString(), oldFileName);
- QCOMPARE(arguments.at(2).toString(), newFileName);
- QCOMPARE(QFile::rename(tmp + '/' + newFileName, tmp + '/' + oldFileName), true);
- }
- QTRY_COMPARE(model->rowCount(tmpIdx), files.count());
- // cleanup
- if (!subdirName.isEmpty())
- QVERIFY(QDir(tmp).removeRecursively());
-}
-
-void tst_QFileSystemModel::sortPersistentIndex()
-{
- QTemporaryFile file(flatDirTestPath + QStringLiteral("/XXXXXX.dat"));
- QVERIFY2(file.open(), qPrintable(file.errorString()));
- const QFileInfo fileInfo(file.fileName());
- file.close();
- QTRY_VERIFY(QDir(flatDirTestPath).entryInfoList().contains(fileInfo));
- QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
- QModelIndex root = model->setRootPath(flatDirTestPath);
- QTRY_VERIFY(model->rowCount(root) > 0);
-
- QPersistentModelIndex idx = model->index(0, 1, root);
- model->sort(0, Qt::AscendingOrder);
- model->sort(0, Qt::DescendingOrder);
- QVERIFY(idx.column() != 0);
-}
-
-class MyFriendFileSystemModel : public QFileSystemModel
-{
- friend class tst_QFileSystemModel;
- Q_DECLARE_PRIVATE(QFileSystemModel)
-};
-
-void tst_QFileSystemModel::sort_data()
-{
- QTest::addColumn<bool>("fileDialogMode");
- QTest::newRow("standard usage") << false;
- QTest::newRow("QFileDialog usage") << true;
-}
-
-void tst_QFileSystemModel::sort()
-{
- QFETCH(bool, fileDialogMode);
-
- QScopedPointer<MyFriendFileSystemModel> myModel(new MyFriendFileSystemModel);
- QTreeView tree;
- tree.setWindowTitle(QTest::currentTestFunction());
-
- if (fileDialogMode && EmulationDetector::isRunningArmOnX86())
- QSKIP("Crashes in QEMU. QTBUG-70572");
-
-#ifdef QT_BUILD_INTERNAL
- if (fileDialogMode)
- myModel->d_func()->disableRecursiveSort = true;
-#endif
-
- QDir dir(flatDirTestPath);
- const QString dirPath = dir.absolutePath();
-
- //Create a file that will be at the end when sorting by name (For Mac, the default)
- //but if we sort by size descending it will be the first
- QFile tempFile(dirPath + "/plop2.txt");
- tempFile.open(QIODevice::WriteOnly | QIODevice::Text);
- QTextStream out(&tempFile);
- out << "The magic number is: " << 49 << "\n";
- tempFile.close();
-
- QFile tempFile2(dirPath + "/plop.txt");
- tempFile2.open(QIODevice::WriteOnly | QIODevice::Text);
- QTextStream out2(&tempFile2);
- out2 << "The magic number is : " << 49 << " but i write some stuff in the file \n";
- tempFile2.close();
-
- myModel->setRootPath("");
- myModel->setFilter(QDir::AllEntries | QDir::System | QDir::Hidden);
- tree.setSortingEnabled(true);
- tree.setModel(myModel.data());
- tree.show();
- tree.resize(800, 800);
- QVERIFY(QTest::qWaitForWindowExposed(&tree));
- tree.header()->setSortIndicator(1, Qt::DescendingOrder);
- tree.header()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
- QStringList dirsToOpen;
- do {
- dirsToOpen << dir.absolutePath();
- } while (dir.cdUp());
-
- for (int i = dirsToOpen.size() -1 ; i > 0 ; --i) {
- QString path = dirsToOpen[i];
- tree.expand(myModel->index(path, 0));
- }
- tree.expand(myModel->index(dirPath, 0));
- QModelIndex parent = myModel->index(dirPath, 0);
- QList<QString> expectedOrder;
- expectedOrder << tempFile2.fileName() << tempFile.fileName() << dirPath + QChar('/') + ".." << dirPath + QChar('/') + ".";
-
- if (fileDialogMode) {
- QTRY_COMPARE(myModel->rowCount(parent), expectedOrder.count());
- // File dialog Mode means sub trees are not sorted, only the current root.
- // There's no way we can check that the sub tree is "not sorted"; just check if it
- // has the same contents of the expected list
- QList<QString> actualRows;
- for(int i = 0; i < myModel->rowCount(parent); ++i)
- {
- actualRows << dirPath + QChar('/') + myModel->index(i, 1, parent).data(QFileSystemModel::FileNameRole).toString();
- }
-
- std::sort(expectedOrder.begin(), expectedOrder.end());
- std::sort(actualRows.begin(), actualRows.end());
-
- QCOMPARE(actualRows, expectedOrder);
- } else {
- for(int i = 0; i < myModel->rowCount(parent); ++i)
- {
- QTRY_COMPARE(dirPath + QChar('/') + myModel->index(i, 1, parent).data(QFileSystemModel::FileNameRole).toString(), expectedOrder.at(i));
- }
- }
-}
-
-void tst_QFileSystemModel::mkdir()
-{
- QString tmp = flatDirTestPath;
- QString newFolderPath = QDir::toNativeSeparators(tmp + '/' + "NewFoldermkdirtest4");
- QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
- QModelIndex tmpDir = model->index(tmp);
- QVERIFY(tmpDir.isValid());
- QDir bestatic(newFolderPath);
- if (bestatic.exists()) {
- if (!bestatic.rmdir(newFolderPath))
- qWarning() << "unable to remove" << newFolderPath;
- QTest::qWait(WAITTIME);
- }
- model->mkdir(tmpDir, "NewFoldermkdirtest3");
- model->mkdir(tmpDir, "NewFoldermkdirtest5");
- QModelIndex idx = model->mkdir(tmpDir, "NewFoldermkdirtest4");
- QVERIFY(idx.isValid());
- int oldRow = idx.row();
- idx = model->index(newFolderPath);
- QVERIFY(idx.isValid());
- QVERIFY(model->remove(idx));
- QVERIFY(!bestatic.exists());
- QVERIFY(0 != idx.row());
- QCOMPARE(oldRow, idx.row());
-}
-
-void tst_QFileSystemModel::deleteFile()
-{
- QString newFilePath = QDir::temp().filePath("NewFileDeleteTest");
- QFile newFile(newFilePath);
- if (newFile.exists()) {
- if (!newFile.remove())
- qWarning() << "unable to remove" << newFilePath;
- QTest::qWait(WAITTIME);
- }
- if (!newFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
- qWarning() << "unable to create" << newFilePath;
- }
- newFile.close();
- QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
- QModelIndex idx = model->index(newFilePath);
- QVERIFY(idx.isValid());
- QVERIFY(model->remove(idx));
- QVERIFY(!newFile.exists());
-}
-
-void tst_QFileSystemModel::deleteDirectory()
-{
- // QTBUG-65683: Verify that directories can be removed recursively despite
- // file system watchers being active on them or their sub-directories (Windows).
- // Create a temporary directory, a nested directory and expand a treeview
- // to show them to ensure watcher creation. Then delete the directory.
- QTemporaryDir dirToBeDeleted(flatDirTestPath + QStringLiteral("/deleteDirectory-XXXXXX"));
- QVERIFY(dirToBeDeleted.isValid());
- const QString dirToBeDeletedPath = dirToBeDeleted.path();
- const QString nestedTestDir = QStringLiteral("test");
- QVERIFY(QDir(dirToBeDeletedPath).mkpath(nestedTestDir));
- const QString nestedTestDirPath = dirToBeDeletedPath + QLatin1Char('/') + nestedTestDir;
- QFile testFile(nestedTestDirPath + QStringLiteral("/test.txt"));
- QVERIFY(testFile.open(QIODevice::WriteOnly | QIODevice::Text));
- testFile.write("Hello\n");
- testFile.close();
-
- QFileSystemModel model;
- const QModelIndex rootIndex = model.setRootPath(flatDirTestPath);
- QTreeView treeView;
- treeView.setWindowTitle(QTest::currentTestFunction());
- treeView.setModel(&model);
- treeView.setRootIndex(rootIndex);
-
- const QModelIndex dirToBeDeletedPathIndex = model.index(dirToBeDeletedPath);
- QVERIFY(dirToBeDeletedPathIndex.isValid());
- treeView.setExpanded(dirToBeDeletedPathIndex, true);
- const QModelIndex nestedTestDirIndex = model.index(nestedTestDirPath);
- QVERIFY(nestedTestDirIndex.isValid());
- treeView.setExpanded(nestedTestDirIndex, true);
-
- treeView.show();
- QVERIFY(QTest::qWaitForWindowExposed(&treeView));
-
- QVERIFY(model.remove(dirToBeDeletedPathIndex));
- dirToBeDeleted.setAutoRemove(false);
-}
-
-static QString flipCase(QString s)
-{
- for (int i = 0, size = s.size(); i < size; ++i) {
- const QChar c = s.at(i);
- if (c.isUpper())
- s[i] = c.toLower();
- else if (c.isLower())
- s[i] = c.toUpper();
- }
- return s;
-}
-
-void tst_QFileSystemModel::caseSensitivity()
-{
- QString tmp = flatDirTestPath;
- QStringList files;
- files << "a" << "c" << "C";
- QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
- QVERIFY(createFiles(model.data(), tmp, files));
- QModelIndex root = model->index(tmp);
- QStringList paths;
- QModelIndexList indexes;
- QCOMPARE(model->rowCount(root), 0);
- for (int i = 0; i < files.count(); ++i) {
- const QString path = tmp + '/' + files.at(i);
- const QModelIndex index = model->index(path);
- QVERIFY(index.isValid());
- paths.append(path);
- indexes.append(index);
- }
-
- if (!QFileSystemEngine::isCaseSensitive()) {
- // QTBUG-31103, QTBUG-64147: Verify that files can be accessed by paths with fLipPeD case.
- for (int i = 0; i < paths.count(); ++i) {
- const QModelIndex flippedCaseIndex = model->index(flipCase(paths.at(i)));
- QCOMPARE(indexes.at(i), flippedCaseIndex);
- }
- }
-}
-
-void tst_QFileSystemModel::drives_data()
-{
- QTest::addColumn<QString>("path");
- QTest::newRow("current") << QDir::currentPath();
- QTest::newRow("slash") << "/";
- QTest::newRow("My Computer") << "My Computer";
-}
-
-void tst_QFileSystemModel::drives()
-{
- QFETCH(QString, path);
- QFileSystemModel model;
- model.setRootPath(path);
- model.fetchMore(QModelIndex());
- QFileInfoList drives = QDir::drives();
- int driveCount = 0;
- foreach(const QFileInfo& driveRoot, drives)
- if (driveRoot.exists())
- driveCount++;
- QTRY_COMPARE(model.rowCount(), driveCount);
-}
-
-void tst_QFileSystemModel::dirsBeforeFiles()
-{
- auto diagnosticMsg = [](int row, const QFileInfo &left, const QFileInfo &right) -> QByteArray {
- QString message;
- QDebug(&message).noquote() << "Unexpected sort order at #" << row << ':' << left << right;
- return message.toLocal8Bit();
- };
- QTemporaryDir testDir(flatDirTestPath);
- QVERIFY2(testDir.isValid(), qPrintable(testDir.errorString()));
- QDir dir(testDir.path());
-
- const int itemCount = 3;
- for (int i = 0; i < itemCount; ++i) {
- QLatin1Char c('a' + char(i));
- QVERIFY(dir.mkdir(c + QLatin1String("-dir")));
- QFile file(dir.filePath(c + QLatin1String("-file")));
- QVERIFY(file.open(QIODevice::ReadWrite));
- file.close();
- }
-
- QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
- QModelIndex root = model->setRootPath(dir.absolutePath());
- // Wait for model to be notified by the file system watcher
- QTRY_COMPARE(model->rowCount(root), 2 * itemCount);
- // sort explicitly - dirs before files (except on macOS), and then by name
- model->sort(0);
- // Ensure that no file occurs before any directory (see QFileSystemModelSorter):
- for (int i = 1, count = model->rowCount(root); i < count; ++i) {
- const QFileInfo previous = model->fileInfo(model->index(i - 1, 0, root));
- const QFileInfo current = model->fileInfo(model->index(i, 0, root));
-#ifndef Q_OS_MAC
- QVERIFY2(!(previous.isFile() && current.isDir()), diagnosticMsg(i, previous, current).constData());
-#else
- QVERIFY2(previous.fileName() < current.fileName(), diagnosticMsg(i, previous, current).constData());
-#endif
- }
-}
-
-void tst_QFileSystemModel::roleNames_data()
-{
- QTest::addColumn<int>("role");
- QTest::addColumn<QByteArray>("roleName");
- QTest::newRow("decoration") << int(Qt::DecorationRole) << QByteArray("fileIcon");
- QTest::newRow("display") << int(Qt::DisplayRole) << QByteArray("display");
- QTest::newRow("fileIcon") << int(QFileSystemModel::FileIconRole) << QByteArray("fileIcon");
- QTest::newRow("filePath") << int(QFileSystemModel::FilePathRole) << QByteArray("filePath");
- QTest::newRow("fileName") << int(QFileSystemModel::FileNameRole) << QByteArray("fileName");
- QTest::newRow("filePermissions") << int(QFileSystemModel::FilePermissions) << QByteArray("filePermissions");
-}
-
-void tst_QFileSystemModel::roleNames()
-{
- QFileSystemModel model;
- QHash<int, QByteArray> roles = model.roleNames();
-
- QFETCH(int, role);
- QVERIFY(roles.contains(role));
-
- QFETCH(QByteArray, roleName);
- QCOMPARE(roles.contains(role), true);
- QCOMPARE(roles.value(role), roleName);
-}
-
-static inline QByteArray permissionRowName(bool readOnly, int permission)
-{
- QByteArray result = readOnly ? QByteArrayLiteral("ro") : QByteArrayLiteral("rw");
- result += QByteArrayLiteral("-0");
- result += QByteArray::number(permission, 16);
- return result;
-}
-
-void tst_QFileSystemModel::permissions_data()
-{
- QTest::addColumn<QFileDevice::Permissions>("permissions");
- QTest::addColumn<bool>("readOnly");
-
- static const int permissions[] = {
- QFile::WriteOwner,
- QFile::ReadOwner,
- QFile::WriteOwner|QFile::ReadOwner,
- };
- for (int permission : permissions) {
- QTest::newRow(permissionRowName(false, permission).constData()) << QFileDevice::Permissions(permission) << false;
- QTest::newRow(permissionRowName(true, permission).constData()) << QFileDevice::Permissions(permission) << true;
- }
-}
-
-void tst_QFileSystemModel::permissions() // checks QTBUG-20503
-{
- QFETCH(QFileDevice::Permissions, permissions);
- QFETCH(bool, readOnly);
-
- const QString tmp = flatDirTestPath;
- const QString file = tmp + QLatin1String("/f");
- QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
- QVERIFY(createFiles(model.data(), tmp, QStringList{QLatin1String("f")}));
-
- QVERIFY(QFile::setPermissions(file, permissions));
-
- const QModelIndex root = model->setRootPath(tmp);
-
- model->setReadOnly(readOnly);
-
- QCOMPARE(model->isReadOnly(), readOnly);
-
- QTRY_COMPARE(model->rowCount(root), 1);
-
- const QFile::Permissions modelPermissions = model->permissions(model->index(0, 0, root));
- const QFile::Permissions modelFileInfoPermissions = model->fileInfo(model->index(0, 0, root)).permissions();
- const QFile::Permissions fileInfoPermissions = QFileInfo(file).permissions();
-
- QCOMPARE(modelPermissions, modelFileInfoPermissions);
- QCOMPARE(modelFileInfoPermissions, fileInfoPermissions);
- QCOMPARE(fileInfoPermissions, modelPermissions);
-}
-
-void tst_QFileSystemModel::doNotUnwatchOnFailedRmdir()
-{
- const QString tmp = flatDirTestPath;
-
- QFileSystemModel model;
-
- const QTemporaryDir tempDir(tmp + '/' + QStringLiteral("doNotUnwatchOnFailedRmdir-XXXXXX"));
- QVERIFY(tempDir.isValid());
-
- const QModelIndex rootIndex = model.setRootPath(tempDir.path());
-
- // create a file in the directory so to prevent it from deletion
- {
- QFile file(tempDir.path() + '/' + QStringLiteral("file1"));
- QVERIFY(file.open(QIODevice::WriteOnly));
- }
-
- QCOMPARE(model.rmdir(rootIndex), false);
-
- // create another file
- {
- QFile file(tempDir.path() + '/' + QStringLiteral("file2"));
- QVERIFY(file.open(QIODevice::WriteOnly));
- }
-
- // the model must now detect this second file
- QTRY_COMPARE(model.rowCount(rootIndex), 2);
-}
-
-static QSet<QString> fileListUnderIndex(const QFileSystemModel *model, const QModelIndex &parent)
-{
- QSet<QString> fileNames;
- const int rowCount = model->rowCount(parent);
- for (int i = 0; i < rowCount; ++i)
- fileNames.insert(model->index(i, 0, parent).data(QFileSystemModel::FileNameRole).toString());
- return fileNames;
-}
-
-void tst_QFileSystemModel::specialFiles()
-{
-#ifndef Q_OS_UNIX
- QSKIP("Not implemented");
-#endif
-
- QFileSystemModel model;
-
- model.setFilter(QDir::AllEntries | QDir::System | QDir::Hidden);
-
- // Can't simply verify if the model returns a valid model index for a special file
- // as it will always return a valid index for existing files,
- // even if the file is not visible with the given filter.
-
- const QModelIndex rootIndex = model.setRootPath(QStringLiteral("/dev/"));
- const QString testFileName = QStringLiteral("null");
-
- QTRY_VERIFY(fileListUnderIndex(&model, rootIndex).contains(testFileName));
-
- model.setFilter(QDir::AllEntries | QDir::Hidden);
-
- QTRY_VERIFY(!fileListUnderIndex(&model, rootIndex).contains(testFileName));
-}
-
-void tst_QFileSystemModel::fileInfo()
-{
- QFileSystemModel model;
- QModelIndex idx;
-
- QVERIFY(model.fileInfo(idx).filePath().isEmpty());
-
- const QString dirPath = flatDirTestPath;
- QDir dir(dirPath);
- const QString subdir = QStringLiteral("subdir");
- QVERIFY(dir.mkdir(subdir));
- const QString subdirPath = dir.absoluteFilePath(subdir);
-
- idx = model.setRootPath(subdirPath);
- QCOMPARE(model.fileInfo(idx), QFileInfo(subdirPath));
- idx = model.setRootPath(dirPath);
- QCOMPARE(model.fileInfo(idx), QFileInfo(dirPath));
-}
-
-QTEST_MAIN(tst_QFileSystemModel)
-#include "tst_qfilesystemmodel.moc"
-
diff --git a/tests/auto/widgets/dialogs/qinputdialog/tst_qinputdialog.cpp b/tests/auto/widgets/dialogs/qinputdialog/tst_qinputdialog.cpp
index 877784041b..2a40af320b 100644
--- a/tests/auto/widgets/dialogs/qinputdialog/tst_qinputdialog.cpp
+++ b/tests/auto/widgets/dialogs/qinputdialog/tst_qinputdialog.cpp
@@ -48,7 +48,7 @@ class tst_QInputDialog : public QObject
static void testFuncGetText(QInputDialog *dialog);
static void testFuncGetItem(QInputDialog *dialog);
static void testFuncSingleStepDouble(QInputDialog *dialog);
- void timerEvent(QTimerEvent *event);
+ void timerEvent(QTimerEvent *event) override;
private slots:
void getInt_data();
void getInt();
diff --git a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp
index 3169a9cb4e..dfb8dc1c37 100644
--- a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp
+++ b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp
@@ -80,7 +80,8 @@ public:
bool resized;
protected:
- void resizeEvent ( QResizeEvent * event ) {
+ void resizeEvent ( QResizeEvent * event ) override
+ {
resized = true;
QMessageBox::resizeEvent(event);
}
diff --git a/tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp b/tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp
index 6f527e7b6b..2149ee7c44 100644
--- a/tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp
+++ b/tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp
@@ -53,6 +53,7 @@ private Q_SLOTS:
void QTBUG_31046();
void settingCustomWidgets();
void i18n();
+ void setValueReentrancyGuard();
};
void tst_QProgressDialog::cleanup()
@@ -291,5 +292,28 @@ void tst_QProgressDialog::i18n()
QVERIFY(!btn->text().startsWith(xxx));
}
+void tst_QProgressDialog::setValueReentrancyGuard()
+{
+ // Tests setValue() of window modal QProgressBar with
+ // Qt::QueuedConnection:
+ // This test crashes with a stack overflow if the boolean
+ // guard "processingEvents" that prevents reentranct calls
+ // to QCoreApplication::processEvents() within setValue()
+ // has not been implemented
+
+ constexpr int steps = 100; // Should be at least 50 to test for crash
+
+ QProgressDialog dlg("Testing setValue reentrancy guard...", QString(), 0, steps);
+ dlg.setWindowModality(Qt::WindowModal);
+ dlg.setMinimumDuration(0);
+ dlg.setAutoReset(false);
+
+ // Simulate a quick work loop
+ for (int i = 0; i <= steps; ++i)
+ QMetaObject::invokeMethod(&dlg, "setValue", Qt::QueuedConnection, Q_ARG(int, i));
+
+ QTRY_COMPARE(dlg.value(), steps);
+}
+
QTEST_MAIN(tst_QProgressDialog)
#include "tst_qprogressdialog.moc"
diff --git a/tests/auto/widgets/dialogs/qsidebar/tst_qsidebar.cpp b/tests/auto/widgets/dialogs/qsidebar/tst_qsidebar.cpp
index 146a9e262d..20866a0fa7 100644
--- a/tests/auto/widgets/dialogs/qsidebar/tst_qsidebar.cpp
+++ b/tests/auto/widgets/dialogs/qsidebar/tst_qsidebar.cpp
@@ -29,7 +29,8 @@
#include <QtTest/QtTest>
#include <QtWidgets/private/qsidebar_p.h>
-#include <QtWidgets/private/qfilesystemmodel_p.h>
+#include <QtGui/private/qfilesystemmodel_p.h>
+#include <QtWidgets/qfileiconprovider.h>
class tst_QSidebar : public QObject {
Q_OBJECT
@@ -40,12 +41,16 @@ private slots:
void addUrls();
void goToUrl();
+
+private:
+ QFileIconProvider defaultIconProvider;
};
void tst_QSidebar::setUrls()
{
QList<QUrl> urls;
QFileSystemModel fsmodel;
+ fsmodel.setIconProvider(&defaultIconProvider);
QSidebar qsidebar;
qsidebar.setModelAndUrls(&fsmodel, urls);
QAbstractItemModel *model = qsidebar.model();
@@ -67,6 +72,7 @@ void tst_QSidebar::selectUrls()
urls << QUrl::fromLocalFile(QDir::rootPath())
<< QUrl::fromLocalFile(QDir::temp().absolutePath());
QFileSystemModel fsmodel;
+ fsmodel.setIconProvider(&defaultIconProvider);
QSidebar qsidebar;
qsidebar.setModelAndUrls(&fsmodel, urls);
@@ -79,6 +85,7 @@ void tst_QSidebar::addUrls()
{
QList<QUrl> emptyUrls;
QFileSystemModel fsmodel;
+ fsmodel.setIconProvider(&defaultIconProvider);
QSidebar qsidebar;
qsidebar.setModelAndUrls(&fsmodel, emptyUrls);
QAbstractItemModel *model = qsidebar.model();
@@ -179,6 +186,7 @@ void tst_QSidebar::goToUrl()
urls << QUrl::fromLocalFile(QDir::rootPath())
<< QUrl::fromLocalFile(QDir::temp().absolutePath());
QFileSystemModel fsmodel;
+ fsmodel.setIconProvider(&defaultIconProvider);
QSidebar qsidebar;
qsidebar.setModelAndUrls(&fsmodel, urls);
qsidebar.show();
diff --git a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp
index e9bf14b1e6..3e8a81c33c 100644
--- a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp
+++ b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp
@@ -821,9 +821,9 @@ struct MyPage2 : public QWizardPage
public:
MyPage2() : init(0), cleanup(0), validate(0) {}
- void initializePage() { ++init; QWizardPage::initializePage(); }
- void cleanupPage() { ++cleanup; QWizardPage::cleanupPage(); }
- bool validatePage() { ++validate; return QWizardPage::validatePage(); }
+ void initializePage() override { ++init; QWizardPage::initializePage(); }
+ void cleanupPage() override { ++cleanup; QWizardPage::cleanupPage(); }
+ bool validatePage() override { ++validate; return QWizardPage::validatePage(); }
bool sanityCheck(int init, int cleanup)
{
@@ -1592,13 +1592,13 @@ protected:
class SetPage : public Operation
{
- void apply(QWizard *wizard) const
+ void apply(QWizard *wizard) const override
{
wizard->restart();
for (int j = 0; j < page; ++j)
wizard->next();
}
- QString describe() const { return QLatin1String("set page ") + QString::number(page); }
+ QString describe() const override { return QLatin1String("set page ") + QString::number(page); }
int page;
public:
static QSharedPointer<SetPage> create(int page)
@@ -1611,8 +1611,8 @@ public:
class SetStyle : public Operation
{
- void apply(QWizard *wizard) const { wizard->setWizardStyle(style); }
- QString describe() const { return QLatin1String("set style ") + QString::number(style); }
+ void apply(QWizard *wizard) const override { wizard->setWizardStyle(style); }
+ QString describe() const override { return QLatin1String("set style ") + QString::number(style); }
QWizard::WizardStyle style;
public:
static QSharedPointer<SetStyle> create(QWizard::WizardStyle style)
@@ -1625,8 +1625,8 @@ public:
class SetOption : public Operation
{
- void apply(QWizard *wizard) const { wizard->setOption(option, on); }
- QString describe() const;
+ void apply(QWizard *wizard) const override { wizard->setOption(option, on); }
+ QString describe() const override;
QWizard::WizardOption option;
bool on;
public:
@@ -2117,8 +2117,8 @@ class WizardPage : public QWizardPage
{
Q_OBJECT
bool shown_;
- void showEvent(QShowEvent *) { shown_ = true; }
- void hideEvent(QHideEvent *) { shown_ = false; }
+ void showEvent(QShowEvent *) override { shown_ = true; }
+ void hideEvent(QHideEvent *) override { shown_ = false; }
public:
WizardPage() : shown_(false) {}
bool shown() const { return shown_; }
@@ -2511,7 +2511,7 @@ private:
QTreeWidget *treeWidget;
QSizePolicy::Policy verticalPolicy;
- void initializePage()
+ void initializePage() override
{
if (layout())
delete layout();
diff --git a/tests/auto/widgets/dialogs/qwizard/tst_qwizard_2.cpp b/tests/auto/widgets/dialogs/qwizard/tst_qwizard_2.cpp
index 0969cecc45..cc48543a76 100644
--- a/tests/auto/widgets/dialogs/qwizard/tst_qwizard_2.cpp
+++ b/tests/auto/widgets/dialogs/qwizard/tst_qwizard_2.cpp
@@ -61,7 +61,7 @@ class taskQTBUG_25691Page2 : public QWizardPage
public:
taskQTBUG_25691Page2( QWidget * parent = 0 );
- virtual void initializePage(void);
+ virtual void initializePage(void) override;
~taskQTBUG_25691Page2(void);
diff --git a/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp b/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp
index 38181c8af0..bd1b56ebc1 100644
--- a/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp
+++ b/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp
@@ -73,7 +73,7 @@ public:
m_painter(0), m_styleOption(0)
{}
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
{
m_painter = painter;
m_styleOption = option;
@@ -101,7 +101,7 @@ public:
doNothingInDraw(false), m_painter(0), m_styleOption(0), m_source(0), m_opacity(1.0)
{}
- QRectF boundingRectFor(const QRectF &rect) const
+ QRectF boundingRectFor(const QRectF &rect) const override
{ return rect.adjusted(-m_margin, -m_margin, m_margin, m_margin); }
void reset()
@@ -123,7 +123,7 @@ public:
int margin() const
{ return m_margin; }
- void draw(QPainter *painter)
+ void draw(QPainter *painter) override
{
++numRepaints;
if (doNothingInDraw)
@@ -135,7 +135,7 @@ public:
drawSource(painter);
}
- void sourceChanged(QGraphicsEffect::ChangeFlags flags)
+ void sourceChanged(QGraphicsEffect::ChangeFlags flags) override
{ m_sourceChangedFlags |= flags; }
int numRepaints;
@@ -509,10 +509,10 @@ public:
, repaints(0)
{}
- QRectF boundingRectFor(const QRectF &rect) const
+ QRectF boundingRectFor(const QRectF &rect) const override
{ return rect; }
- void draw(QPainter *painter)
+ void draw(QPainter *painter) override
{
QCOMPARE(sourcePixmap(Qt::LogicalCoordinates).handle(), pixmap.handle());
QVERIFY((painter->worldTransform().type() <= QTransform::TxTranslate) == (sourcePixmap(Qt::DeviceCoordinates).handle() == pixmap.handle()));
@@ -551,10 +551,10 @@ void tst_QGraphicsEffect::drawPixmapItem()
class DeviceEffect : public QGraphicsEffect
{
public:
- QRectF boundingRectFor(const QRectF &rect) const
+ QRectF boundingRectFor(const QRectF &rect) const override
{ return rect; }
- void draw(QPainter *painter)
+ void draw(QPainter *painter) override
{
QPoint offset;
QPixmap pixmap = sourcePixmap(Qt::DeviceCoordinates, &offset, QGraphicsEffect::NoPad);
@@ -648,7 +648,7 @@ public:
MyGraphicsItem(QGraphicsItem *parent = 0) :
QGraphicsWidget(parent), nbPaint(0)
{}
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
{
nbPaint++;
QGraphicsWidget::paint(painter, option, widget);
diff --git a/tests/auto/widgets/effects/qpixmapfilter/tst_qpixmapfilter.cpp b/tests/auto/widgets/effects/qpixmapfilter/tst_qpixmapfilter.cpp
index 7d7c1e79a9..5cc08617c6 100644
--- a/tests/auto/widgets/effects/qpixmapfilter/tst_qpixmapfilter.cpp
+++ b/tests/auto/widgets/effects/qpixmapfilter/tst_qpixmapfilter.cpp
@@ -59,7 +59,8 @@ public:
CustomFilter() : QPixmapFilter((QPixmapFilter::FilterType) Type, 0) { };
- void draw(QPainter *p, const QPointF &pt, const QPixmap &src, const QRectF &srcRect = QRectF()) const {
+ void draw(QPainter *p, const QPointF &pt, const QPixmap &src, const QRectF &srcRect = QRectF()) const override
+ {
p->drawPixmap(QRectF(pt, srcRect.size()), src, srcRect);
}
};
@@ -400,13 +401,13 @@ void tst_QPixmapFilter::blurIndexed8()
QImage original = img;
qt_blurImage(img, 10, true, false);
QCOMPARE(original.size(), img.size());
- QVERIFY2(qFuzzyCompare(img.devicePixelRatioF(), qreal(2)),
- QByteArray::number(img.devicePixelRatioF()).constData());
+ QVERIFY2(qFuzzyCompare(img.devicePixelRatio(), qreal(2)),
+ QByteArray::number(img.devicePixelRatio()).constData());
original = img;
qt_blurImage(img, 10, true, true);
- QVERIFY2(qFuzzyCompare(img.devicePixelRatioF(), qreal(2)),
- QByteArray::number(img.devicePixelRatioF()).constData());
+ QVERIFY2(qFuzzyCompare(img.devicePixelRatio(), qreal(2)),
+ QByteArray::number(img.devicePixelRatio()).constData());
QCOMPARE(original.size(), QSize(img.height(), img.width()));
}
diff --git a/tests/auto/widgets/graphicsview/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/widgets/graphicsview/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
index e19ef4c308..934505034e 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
@@ -87,7 +87,7 @@ class RectWidget : public QGraphicsWidget
public:
RectWidget(QGraphicsItem *parent = 0) : QGraphicsWidget(parent){}
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
{
Q_UNUSED(option);
Q_UNUSED(widget);
@@ -1113,7 +1113,7 @@ public:
}
virtual int pixelMetric(PixelMetric metric, const QStyleOption * option = 0,
- const QWidget * widget = 0 ) const;
+ const QWidget * widget = 0 ) const override;
int hspacing;
int vspacing;
@@ -1122,7 +1122,7 @@ public:
QSizePolicy::ControlType control2,
Qt::Orientation orientation,
const QStyleOption *option = 0,
- const QWidget *widget = 0) const;
+ const QWidget *widget = 0) const override;
};
diff --git a/tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp b/tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp
index 65480bf665..d1f8954ab9 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp
@@ -163,7 +163,7 @@ public:
}
protected:
- QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;
+ QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const override;
};
QSizeF TestWidget::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
diff --git a/tests/auto/widgets/graphicsview/qgraphicseffectsource/tst_qgraphicseffectsource.cpp b/tests/auto/widgets/graphicsview/qgraphicseffectsource/tst_qgraphicseffectsource.cpp
index eaad5e478d..5df8b7c1ac 100644
--- a/tests/auto/widgets/graphicsview/qgraphicseffectsource/tst_qgraphicseffectsource.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicseffectsource/tst_qgraphicseffectsource.cpp
@@ -43,7 +43,7 @@ public:
m_painter(0)
{}
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
{
m_painter = painter;
++numRepaints;
@@ -70,7 +70,7 @@ public:
m_painter(0), m_source(0)
{}
- QRectF boundingRectFor(const QRectF &rect) const
+ QRectF boundingRectFor(const QRectF &rect) const override
{ return rect.adjusted(-m_margin, -m_margin, m_margin, m_margin); }
void reset()
@@ -94,7 +94,7 @@ public:
int margin() const
{ return m_margin; }
- void draw(QPainter *painter)
+ void draw(QPainter *painter) override
{
++numRepaints;
if (storeDeviceDependentStuff) {
@@ -109,7 +109,7 @@ public:
source()->draw(painter);
}
- void sourceChanged(ChangeFlags)
+ void sourceChanged(ChangeFlags) override
{ m_sourceChanged = true; }
void sourceBoundingRectChanged()
@@ -310,11 +310,13 @@ public:
{
}
- QRectF boundingRectFor(const QRectF &src) const {
+ QRectF boundingRectFor(const QRectF &src) const override
+ {
return src.adjusted(-10, -10, 10, 10);
}
- void draw(QPainter *) {
+ void draw(QPainter *) override
+ {
pix = source()->pixmap(coordinateMode, &offset, padMode);
}
diff --git a/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
index 4d5857c3c8..7e7536a94c 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
@@ -121,7 +121,7 @@ class RectWidget : public QGraphicsWidget
public:
RectWidget(QGraphicsItem *parent = 0) : QGraphicsWidget(parent), m_fnConstraint(0) {}
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
{
Q_UNUSED(option);
Q_UNUSED(widget);
@@ -130,7 +130,7 @@ public:
painter->drawLine(rect().bottomLeft(), rect().topRight());
}
- QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const
+ QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const override
{
if (constraint.width() < 0 && constraint.height() < 0 && m_sizeHints[which].isValid()) {
return m_sizeHints[which];
diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
index aa08f1c44d..280b12b173 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -286,9 +286,6 @@ class tst_QGraphicsItem : public QObject
{
Q_OBJECT
-public:
- static void initMain();
-
private slots:
void cleanup();
void construction();
@@ -494,14 +491,6 @@ private:
QPointingDevice *m_touchDevice = QTest::createTouchDevice();
};
-void tst_QGraphicsItem::initMain()
-{
-#ifdef Q_OS_WIN
- // Ensure minimum size constraints of framed windows on High DPI screens
- QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
-#endif
-}
-
void tst_QGraphicsItem::cleanup()
{
QVERIFY(QApplication::topLevelWidgets().isEmpty());
@@ -7979,7 +7968,6 @@ public:
} else {
QVERIFY(option->exposedRect != QRect());
QVERIFY(option->exposedRect != boundingRect());
- QCOMPARE(option->matrix, sceneTransform());
}
}
QGraphicsRectItem::paint(painter, option, widget);
diff --git a/tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp b/tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp
index c5009e9847..cc416f76b2 100644
--- a/tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp
@@ -93,7 +93,8 @@ public:
TestGraphicsWidget(QGraphicsWidget *parent = 0) : QGraphicsWidget(parent)
{ }
- bool event(QEvent *e) {
+ bool event(QEvent *e) override
+ {
++(m_eventCount[int(e->type())]);
return QGraphicsWidget::event(e);
}
@@ -111,7 +112,7 @@ public:
functionCount.clear();
}
- void setGeometry(const QRectF &rect)
+ void setGeometry(const QRectF &rect) override
{
QGraphicsWidget::setGeometry(rect);
++(functionCount[SetGeometry]);
@@ -235,13 +236,13 @@ class TestLayout : public QGraphicsLinearLayout
setSpacing(0);
}
- void setGeometry(const QRectF &rect)
+ void setGeometry(const QRectF &rect) override
{
++(functionCount[SetGeometry]);
QGraphicsLinearLayout::setGeometry(rect);
}
- void invalidate()
+ void invalidate() override
{
++(functionCount[Invalidate]);
QGraphicsLinearLayout::invalidate();
@@ -569,27 +570,29 @@ class Layout : public QGraphicsLayout
public:
Layout(QGraphicsLayoutItem *parentItem = 0) : QGraphicsLayout(parentItem) {}
- void setGeometry(const QRectF &rect)
+ void setGeometry(const QRectF &rect) override
{
QGraphicsLayout::setGeometry(rect);
}
- int count() const {
+ int count() const override
+ {
return 0;
}
- QGraphicsLayoutItem *itemAt(int index) const {
+ QGraphicsLayoutItem *itemAt(int index) const override
+ {
Q_UNUSED(index);
return 0;
}
- void removeAt(int index)
+ void removeAt(int index) override
{
Q_UNUSED(index);
}
protected:
- QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const
+ QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const override
{
Q_UNUSED(constraint);
Q_UNUSED(which);
@@ -634,9 +637,9 @@ public:
setGraphicsItem(item);
}
- void setGeometry(const QRectF &geom);
+ void setGeometry(const QRectF &geom) override;
- QSizeF sizeHint(Qt::SizeHint which, const QSizeF & constraint = QSizeF() ) const;
+ QSizeF sizeHint(Qt::SizeHint which, const QSizeF & constraint = QSizeF() ) const override;
inline QGraphicsRectItem *rectItem() {
return static_cast<QGraphicsRectItem *>(graphicsItem());
@@ -674,7 +677,8 @@ public:
connect(&m_timeline, SIGNAL(valueChanged(qreal)), this, SLOT(valueChanged(qreal)));
}
- void setGeometry(const QRectF &geom) {
+ void setGeometry(const QRectF &geom) override
+ {
fromGeoms.clear();
toGeoms.clear();
for (int i = 0; i < count(); ++i) {
@@ -759,7 +763,7 @@ public:
setOwnedByLayout(true);
}
- QSizeF sizeHint(Qt::SizeHint which, const QSizeF & constraint = QSizeF() ) const;
+ QSizeF sizeHint(Qt::SizeHint which, const QSizeF & constraint = QSizeF() ) const override;
~CustomLayoutItem() {
m_destructedSet->insert(this);
@@ -790,9 +794,9 @@ public:
m_destructedSet = destructedSet;
}
- QSizeF sizeHint(Qt::SizeHint which, const QSizeF & constraint = QSizeF() ) const;
+ QSizeF sizeHint(Qt::SizeHint which, const QSizeF & constraint = QSizeF() ) const override;
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget * = 0)
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget * = 0) override
{
const QRect r = option->rect.adjusted(0, 0, -1, -1);
painter->drawLine(r.topLeft(), r.bottomRight());
@@ -844,18 +848,18 @@ CustomLayout(QGraphicsLayoutItem *parent)
{
}
-int count() const
+int count() const override
{
return items.count();
}
-QGraphicsLayoutItem* itemAt(int index) const
+QGraphicsLayoutItem* itemAt(int index) const override
{
return items.at(index);
}
-void removeAt(int index)
+void removeAt(int index) override
{
items.removeAt(index);
}
@@ -897,7 +901,7 @@ void updateParentWidget(QGraphicsWidget *item)
}
}
-QSizeF sizeHint(Qt::SizeHint /* which */, const QSizeF & /* constraint */) const
+QSizeF sizeHint(Qt::SizeHint /* which */, const QSizeF & /* constraint */) const override
{
return QSizeF(50,50);
}
diff --git a/tests/auto/widgets/graphicsview/qgraphicslayoutitem/tst_qgraphicslayoutitem.cpp b/tests/auto/widgets/graphicsview/qgraphicslayoutitem/tst_qgraphicslayoutitem.cpp
index af21b9f391..2d8bf40ee5 100644
--- a/tests/auto/widgets/graphicsview/qgraphicslayoutitem/tst_qgraphicslayoutitem.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicslayoutitem/tst_qgraphicslayoutitem.cpp
@@ -72,13 +72,13 @@ public:
{ return QRectF(); }
// QGraphicsLayoutItem::setGeometry is a pure virtual function
- void setGeometry(QRectF const&) {}
+ void setGeometry(QRectF const&) override {}
// QGraphicsLayoutItem::sizeHint is a pure virtual function
- QSizeF sizeHint(Qt::SizeHint, QSizeF const& = QSizeF()) const
+ QSizeF sizeHint(Qt::SizeHint, QSizeF const& = QSizeF()) const override
{ return QSizeF(); }
- void updateGeometry()
+ void updateGeometry() override
{ updateGeometryCalled++; QGraphicsLayoutItem::updateGeometry(); }
int updateGeometryCalled;
diff --git a/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp b/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
index 817f67540e..0851b20927 100644
--- a/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
@@ -107,7 +107,7 @@ public:
layoutDirectionChange(0)
{ }
- void widgetEvent(QEvent *e)
+ void widgetEvent(QEvent *e) override
{
switch (e->type()) {
case QEvent::GraphicsSceneResize:
@@ -145,7 +145,7 @@ class RectWidget : public QGraphicsWidget
public:
RectWidget(QGraphicsItem *parent = 0, const QBrush &brush = QBrush()) : QGraphicsWidget(parent){ m_brush = brush;}
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
{
Q_UNUSED(option);
Q_UNUSED(widget);
@@ -158,7 +158,8 @@ public:
updateGeometry();
}
- virtual QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const {
+ virtual QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const override
+ {
if (m_sizeHints[which].isValid()) {
return m_sizeHints[which];
}
diff --git a/tests/auto/widgets/graphicsview/qgraphicsobject/tst_qgraphicsobject.cpp b/tests/auto/widgets/graphicsview/qgraphicsobject/tst_qgraphicsobject.cpp
index 6ef17a14af..ddcdc809d9 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsobject/tst_qgraphicsobject.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsobject/tst_qgraphicsobject.cpp
@@ -53,8 +53,8 @@ class MyGraphicsObject : public QGraphicsObject
{
public:
MyGraphicsObject() : QGraphicsObject() {}
- virtual QRectF boundingRect() const { return QRectF(); }
- virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) {}
+ virtual QRectF boundingRect() const override { return QRectF(); }
+ virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) override {}
};
void tst_QGraphicsObject::pos()
@@ -223,9 +223,9 @@ public:
}
}
- void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = 0)
+ void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = 0) override
{ }
- QRectF boundingRect() const
+ QRectF boundingRect() const override
{ return QRectF(); }
bool *wasDeleted;
diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
index ebf340db2a..34f27dbfcf 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
@@ -943,7 +943,7 @@ public:
installEventFilter(this);
}
- void enterEvent(QEvent *event)
+ void enterEvent(QEnterEvent *event)
{
enterCount++;
QWidget::enterEvent(event);
diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/.prev_CMakeLists.txt b/tests/auto/widgets/graphicsview/qgraphicsscene/.prev_CMakeLists.txt
new file mode 100644
index 0000000000..3208cf2b36
--- /dev/null
+++ b/tests/auto/widgets/graphicsview/qgraphicsscene/.prev_CMakeLists.txt
@@ -0,0 +1,77 @@
+# Generated from qgraphicsscene.pro.
+
+#####################################################################
+## tst_qgraphicsscene Test:
+#####################################################################
+
+qt_add_test(tst_qgraphicsscene
+ SOURCES
+ tst_qgraphicsscene.cpp
+ DEFINES
+ QT_NO_CAST_TO_ASCII
+ SRCDIR=\\\"${CMAKE_CURRENT_SOURCE_DIR}\\\"
+ PUBLIC_LIBRARIES
+ Qt::CorePrivate
+ Qt::Gui
+ Qt::GuiPrivate
+ Qt::Widgets
+ Qt::WidgetsPrivate
+)
+
+# Resources:
+set(images_resource_files
+ "Ash_European.jpg"
+)
+
+qt_add_resource(tst_qgraphicsscene "images"
+ PREFIX
+ "/"
+ FILES
+ ${images_resource_files}
+)
+set(testdata_resource_files
+ "testData/render/all-all-45-deg-left.png"
+ "testData/render/all-all-45-deg-right.png"
+ "testData/render/all-all-scale-2x.png"
+ "testData/render/all-all-translate-0-50.png"
+ "testData/render/all-all-translate-50-0.png"
+ "testData/render/all-all-untransformed-clip-ellipse.png"
+ "testData/render/all-all-untransformed-clip-rect.png"
+ "testData/render/all-all-untransformed.png"
+ "testData/render/all-bottomleft-untransformed.png"
+ "testData/render/all-bottomright-untransformed.png"
+ "testData/render/all-topleft-untransformed.png"
+ "testData/render/all-topright-untransformed.png"
+ "testData/render/bottom-bottomright-untransformed.png"
+ "testData/render/bottom-topleft-untransformed.png"
+ "testData/render/bottomleft-all-untransformed.png"
+ "testData/render/bottomleft-topleft-untransformed.png"
+ "testData/render/bottomright-all-untransformed.png"
+ "testData/render/bottomright-topleft-untransformed.png"
+ "testData/render/left-bottomright-untransformed.png"
+ "testData/render/left-topleft-untransformed.png"
+ "testData/render/right-bottomright-untransformed.png"
+ "testData/render/right-topleft-untransformed.png"
+ "testData/render/top-bottomright-untransformed.png"
+ "testData/render/top-topleft-untransformed.png"
+ "testData/render/topleft-all-untransformed.png"
+ "testData/render/topleft-topleft-untransformed.png"
+ "testData/render/topright-all-untransformed.png"
+ "testData/render/topright-topleft-untransformed.png"
+)
+
+qt_add_resource(tst_qgraphicsscene "testdata"
+ PREFIX
+ "/"
+ FILES
+ ${testdata_resource_files}
+)
+
+
+## Scopes:
+#####################################################################
+
+qt_extend_target(tst_qgraphicsscene CONDITION WIN32
+ PUBLIC_LIBRARIES
+ user32
+)
diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/CMakeLists.txt b/tests/auto/widgets/graphicsview/qgraphicsscene/CMakeLists.txt
index 3208cf2b36..b17d328446 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsscene/CMakeLists.txt
+++ b/tests/auto/widgets/graphicsview/qgraphicsscene/CMakeLists.txt
@@ -5,6 +5,7 @@
#####################################################################
qt_add_test(tst_qgraphicsscene
+ LOWDPI # special case
SOURCES
tst_qgraphicsscene.cpp
DEFINES
diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/qgraphicsscene.pro b/tests/auto/widgets/graphicsview/qgraphicsscene/qgraphicsscene.pro
index fe8e83ee0a..72c6169afd 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsscene/qgraphicsscene.pro
+++ b/tests/auto/widgets/graphicsview/qgraphicsscene/qgraphicsscene.pro
@@ -1,4 +1,4 @@
-CONFIG += testcase
+CONFIG += testcase testcase_lowdpi
TARGET = tst_qgraphicsscene
QT += widgets widgets-private testlib
QT += core-private gui-private
diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
index 5ecb401284..94130e25bf 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
@@ -122,7 +122,7 @@ public:
bool isHovered = false;
protected:
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *)
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *) override
{
isHovered = (option->state & QStyle::State_MouseOver);
@@ -185,7 +185,6 @@ class tst_QGraphicsScene : public QObject
Q_OBJECT
public:
tst_QGraphicsScene();
- static void initMain() { QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling); }
public slots:
void cleanup();
@@ -289,6 +288,7 @@ private slots:
void taskQTBUG_15977_renderWithDeviceCoordinateCache();
void taskQTBUG_16401_focusItem();
void taskQTBUG_42915_focusNextPrevChild();
+ void taskQTBUG_85088_previewTextfailWhenLostFocus();
private:
QRect m_availableGeometry = QGuiApplication::primaryScreen()->availableGeometry();
@@ -2191,7 +2191,7 @@ public:
bool ignoresDragMove = false;
protected:
- void dragEnterEvent(QGraphicsSceneDragDropEvent *event)
+ void dragEnterEvent(QGraphicsSceneDragDropEvent *event) override
{
storeLastEvent(event);
event->setAccepted(!ignoresDragEnter);
@@ -2200,20 +2200,20 @@ protected:
eventList << event->type();
}
- void dragMoveEvent(QGraphicsSceneDragDropEvent *event)
+ void dragMoveEvent(QGraphicsSceneDragDropEvent *event) override
{
storeLastEvent(event);
event->setAccepted(!ignoresDragMove);
eventList << event->type();
}
- void dragLeaveEvent(QGraphicsSceneDragDropEvent *event)
+ void dragLeaveEvent(QGraphicsSceneDragDropEvent *event) override
{
storeLastEvent(event);
eventList << event->type();
}
- void dropEvent(QGraphicsSceneDragDropEvent *event)
+ void dropEvent(QGraphicsSceneDragDropEvent *event) override
{
storeLastEvent(event);
eventList << event->type();
@@ -3868,7 +3868,7 @@ void tst_QGraphicsScene::inputMethod()
item->eventCalls = 0;
QCoreApplication::sendEvent(&scene, &event);
- QCOMPARE(item->eventCalls, 0);
+ QCOMPARE(item->eventCalls, callFocusItem ? 1 : 0);
item->queryCalls = 0;
scene.inputMethodQuery(Qt::InputMethodQuery(0));
@@ -4933,5 +4933,38 @@ void tst_QGraphicsScene::taskQTBUG_42915_focusNextPrevChild()
QTest::keyEvent(QTest::Click, &view, Qt::Key_Tab);
}
+void tst_QGraphicsScene::taskQTBUG_85088_previewTextfailWhenLostFocus()
+{
+ QString str = "simpleTextItem";
+ QGraphicsScene scene;
+ QGraphicsView view(&scene);
+
+ QGraphicsTextItem *simpleTextItem = new QGraphicsTextItem;
+ simpleTextItem->setFlag(QGraphicsTextItem::ItemIsFocusScope);
+ simpleTextItem->setTextInteractionFlags(Qt::TextEditorInteraction);
+ simpleTextItem->setPlainText(str);
+ scene.addItem(simpleTextItem);
+
+ scene.setFocusItem(simpleTextItem);
+ view.setGeometry(100, 100, 600, 400);
+ view.show();
+
+ QInputMethodEvent inputEvent;
+ QString &preedictStr = const_cast<QString &>(inputEvent.preeditString());
+ preedictStr = str;
+ QApplication::sendEvent(&scene, &inputEvent);
+ QCOMPARE(simpleTextItem->toPlainText(), str);
+
+ // focusItem will lose focus
+ QMouseEvent pressEvent(QEvent::MouseButtonPress, QPointF(0, 0),
+ Qt::LeftButton, Qt::NoButton, Qt::NoModifier);
+ QApplication::sendEvent(view.viewport(), &pressEvent);
+
+ preedictStr.clear();
+ inputEvent.setCommitString(str);
+ QApplication::sendEvent(&scene, &inputEvent);
+ QCOMPARE(simpleTextItem->toPlainText(), str + str);
+}
+
QTEST_MAIN(tst_QGraphicsScene)
#include "tst_qgraphicsscene.moc"
diff --git a/tests/auto/widgets/graphicsview/qgraphicssceneindex/tst_qgraphicssceneindex.cpp b/tests/auto/widgets/graphicsview/qgraphicssceneindex/tst_qgraphicssceneindex.cpp
index 4f2c310135..d875eb1db4 100644
--- a/tests/auto/widgets/graphicsview/qgraphicssceneindex/tst_qgraphicssceneindex.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicssceneindex/tst_qgraphicssceneindex.cpp
@@ -228,9 +228,9 @@ class CustomShapeItem : public QGraphicsItem
public:
CustomShapeItem(const QPainterPath &shape) : QGraphicsItem(0), mShape(shape) {}
- QPainterPath shape() const { return mShape; }
- QRectF boundingRect() const { return mShape.boundingRect(); }
- void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) {}
+ QPainterPath shape() const override { return mShape; }
+ QRectF boundingRect() const override { return mShape.boundingRect(); }
+ void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override {}
private:
QPainterPath mShape;
};
@@ -281,7 +281,7 @@ public:
{
}
- void paint(QPainter *painter, const QStyleOptionGraphicsItem * /* option */, QWidget * /* widget */)
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem * /* option */, QWidget * /* widget */) override
{
painter->setBrush(brush);
painter->drawRect(boundingRect());
@@ -336,8 +336,8 @@ void tst_QGraphicsSceneIndex::clear()
MyItem(QGraphicsItem *parent = 0) : QGraphicsItem(parent), numPaints(0) {}
int numPaints;
protected:
- QRectF boundingRect() const { return QRectF(0, 0, 10, 10); }
- void paint(QPainter * /* painter */, const QStyleOptionGraphicsItem *, QWidget *)
+ QRectF boundingRect() const override { return QRectF(0, 0, 10, 10); }
+ void paint(QPainter * /* painter */, const QStyleOptionGraphicsItem *, QWidget *) override
{ ++numPaints; }
};
diff --git a/tests/auto/widgets/graphicsview/qgraphicstransform/tst_qgraphicstransform.cpp b/tests/auto/widgets/graphicsview/qgraphicstransform/tst_qgraphicstransform.cpp
index da3270d527..d23ccedc6f 100644
--- a/tests/auto/widgets/graphicsview/qgraphicstransform/tst_qgraphicstransform.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicstransform/tst_qgraphicstransform.cpp
@@ -116,7 +116,7 @@ void tst_QGraphicsTransform::scale()
// fuzzyCompareNonZero is a very slightly looser version of qFuzzyCompare
// for use with values that are not very close to zero
-Q_DECL_CONSTEXPR static inline bool fuzzyCompareNonZero(float p1, float p2)
+constexpr static inline bool fuzzyCompareNonZero(float p1, float p2)
{
return (qAbs(p1 - p2) <= 0.00003f * qMin(qAbs(p1), qAbs(p2)));
}
diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
index 84841428f0..42a16dc1f4 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
@@ -113,7 +113,7 @@ public:
void reset() { _count = 0; }
protected:
- bool eventFilter(QObject *watched, QEvent *event)
+ bool eventFilter(QObject *watched, QEvent *event) override
{
Q_UNUSED(watched);
if (event->type() == spied)
@@ -315,13 +315,13 @@ void tst_QGraphicsView::construction()
class TestItem : public QGraphicsItem
{
public:
- QRectF boundingRect() const
+ QRectF boundingRect() const override
{ return QRectF(-10, -10, 20, 20); }
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) override
{ hints = painter->renderHints(); painter->drawRect(boundingRect()); }
- bool sceneEvent(QEvent *event)
+ bool sceneEvent(QEvent *event) override
{
events << event->type();
return QGraphicsItem::sceneEvent(event);
@@ -1593,7 +1593,7 @@ public:
: QGraphicsRectItem(rect), numPaints(0)
{ }
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0)
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) override
{
++numPaints;
QGraphicsRectItem::paint(painter, option, widget);
@@ -2188,7 +2188,7 @@ class MouseWheelScene : public QGraphicsScene
public:
Qt::Orientation orientation;
- void wheelEvent(QGraphicsSceneWheelEvent *event)
+ void wheelEvent(QGraphicsSceneWheelEvent *event) override
{
orientation = event->orientation();
QGraphicsScene::wheelEvent(event);
@@ -2429,7 +2429,7 @@ public:
bool painted;
protected:
- void paintEvent(QPaintEvent *event)
+ void paintEvent(QPaintEvent *event) override
{
lastUpdateRegions << event->region();
painted = true;
@@ -2634,7 +2634,7 @@ public:
using QGraphicsRectItem::QGraphicsRectItem;
bool dirtyPainter = false;
bool receivedPaintEvent = false;
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *w)
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *w) override
{
receivedPaintEvent = true;
dirtyPainter = (painter->pen().color() != w->palette().color(w->foregroundRole()));
@@ -2648,12 +2648,14 @@ public:
MyGraphicsView(QGraphicsScene * scene) : QGraphicsView(scene)
{ }
- void drawBackground(QPainter * painter, const QRectF & rect) {
+ void drawBackground(QPainter * painter, const QRectF & rect) override
+ {
painter->setCompositionMode(QPainter::CompositionMode_Source);
painter->drawRect(rect);
}
- void drawItems (QPainter * painter, int numItems, QGraphicsItem *items[], const QStyleOptionGraphicsItem options[]) {
+ void drawItems (QPainter * painter, int numItems, QGraphicsItem *items[], const QStyleOptionGraphicsItem options[]) override
+ {
if (!(optimizationFlags() & QGraphicsView::DontSavePainterState))
QCOMPARE(painter->compositionMode(),QPainter::CompositionMode_SourceOver);
else
@@ -2721,10 +2723,10 @@ void tst_QGraphicsView::optimizationFlags_dontSavePainterState2()
class MyScene : public QGraphicsScene
{
public:
- void drawBackground(QPainter *p, const QRectF &)
+ void drawBackground(QPainter *p, const QRectF &) override
{ transformInDrawBackground = p->worldTransform(); opacityInDrawBackground = p->opacity(); }
- void drawForeground(QPainter *p, const QRectF &)
+ void drawForeground(QPainter *p, const QRectF &) override
{ transformInDrawForeground = p->worldTransform(); opacityInDrawForeground = p->opacity(); }
QTransform transformInDrawBackground;
@@ -2800,7 +2802,7 @@ public:
LodItem(const QRectF &rect) : QGraphicsRectItem(rect), lastLod(-42)
{ }
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *viewport)
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *viewport) override
{
lastLod = option->levelOfDetailFromTransform(painter->worldTransform());
QGraphicsRectItem::paint(painter, option, viewport);
@@ -2863,14 +2865,15 @@ void tst_QGraphicsView::scrollBarRanges_data()
// Simulates motif scrollbar for range tests
class FauxMotifStyle : public QCommonStyle {
public:
- int styleHint(StyleHint hint, const QStyleOption *option,
- const QWidget *widget, QStyleHintReturn *returnData) const {
+ int styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget, QStyleHintReturn *returnData) const override
+ {
if (hint == QStyle::SH_ScrollView_FrameOnlyAroundContents)
return true;
return QCommonStyle::styleHint(hint, option, widget, returnData);
}
- int pixelMetric(PixelMetric m, const QStyleOption *opt, const QWidget *widget) const {
+ int pixelMetric(PixelMetric m, const QStyleOption *opt, const QWidget *widget) const override
+ {
if (m == QStyle::PM_ScrollView_ScrollBarSpacing)
return 4;
return QCommonStyle::pixelMetric(m, opt, widget);
@@ -2892,7 +2895,7 @@ void tst_QGraphicsView::scrollBarRanges()
QFETCH(ExpectedValueDescription, vmax);
QFETCH(bool, useStyledPanel);
- if (useStyledPanel && style == "macintosh" && platformName == QStringLiteral("cocoa"))
+ if (useStyledPanel && style == "macOS" && platformName == QStringLiteral("cocoa"))
QSKIP("Insignificant on OSX");
QScopedPointer<QStyle> stylePtr;
@@ -2959,12 +2962,12 @@ public:
bool doubleClickAccepted;
protected:
- void mousePressEvent(QMouseEvent *event)
+ void mousePressEvent(QMouseEvent *event) override
{
QGraphicsView::mousePressEvent(event);
pressAccepted = event->isAccepted();
}
- void mouseDoubleClickEvent(QMouseEvent *event)
+ void mouseDoubleClickEvent(QMouseEvent *event) override
{
QGraphicsView::mouseDoubleClickEvent(event);
doubleClickAccepted = event->isAccepted();
@@ -3020,12 +3023,12 @@ public:
bool doubleClickForwarded;
protected:
- void mousePressEvent(QMouseEvent *event)
+ void mousePressEvent(QMouseEvent *event) override
{
QWidget::mousePressEvent(event);
pressForwarded = true;
}
- void mouseDoubleClickEvent(QMouseEvent *event)
+ void mouseDoubleClickEvent(QMouseEvent *event) override
{
QWidget::mouseDoubleClickEvent(event);
doubleClickForwarded = true;
@@ -3152,7 +3155,7 @@ public:
QGraphicsTextItem_task172231(const QString & text, QGraphicsItem * parent = 0)
: QGraphicsTextItem(text, parent) {}
QRectF exposedRect;
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
{
exposedRect = option->exposedRect;
QGraphicsTextItem::paint(painter, option, widget);
@@ -3202,9 +3205,9 @@ public:
int releases;
protected:
- void mousePressEvent(QGraphicsSceneMouseEvent *event)
+ void mousePressEvent(QGraphicsSceneMouseEvent *event) override
{ ++presses; QGraphicsScene::mousePressEvent(event); }
- void mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
+ void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override
{ ++releases; QGraphicsScene::mouseReleaseEvent(event); }
};
@@ -3257,7 +3260,7 @@ public:
{ }
int mouseMoves;
protected:
- void mouseMoveEvent(QMouseEvent *event)
+ void mouseMoveEvent(QMouseEvent *event) override
{
++mouseMoves;
QGraphicsView::mouseMoveEvent(event);
@@ -3310,7 +3313,7 @@ void tst_QGraphicsView::task207546_focusCrash()
class _Widget : public QWidget
{
public:
- bool focusNextPrevChild(bool next) { return QWidget::focusNextPrevChild(next); }
+ bool focusNextPrevChild(bool next) override { return QWidget::focusNextPrevChild(next); }
} widget;
widget.setLayout(new QVBoxLayout());
@@ -3487,7 +3490,7 @@ public:
{
}
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) override
{
transform = painter->transform();
}
@@ -3612,7 +3615,7 @@ void tst_QGraphicsView::moveItemWhileScrolling()
}
protected:
QEventLoop eventLoop;
- void paintEvent(QPaintEvent *event)
+ void paintEvent(QPaintEvent *event) override
{
painted = true;
lastPaintedRegion = event->region();
@@ -3918,8 +3921,7 @@ public:
: QGraphicsRectItem(rect), paints(0)
{ }
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
- QWidget *widget)
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
{
QGraphicsRectItem::paint(painter, option, widget);
++paints;
@@ -4306,7 +4308,7 @@ public:
m_viewHasIMEnabledInFocusInEvent = false;
}
- void focusInEvent(QFocusEvent * /* event */)
+ void focusInEvent(QFocusEvent * /* event */) override
{
QGraphicsView *view = scene()->views().first();
m_viewHasIMEnabledInFocusInEvent = view->testAttribute(Qt::WA_InputMethodEnabled);
@@ -4470,7 +4472,7 @@ void tst_QGraphicsView::indirectPainting()
class MyScene : public QGraphicsScene
{ public:
MyScene() : QGraphicsScene(), drawCount(0) {}
- void drawItems(QPainter *, int, QGraphicsItem **, const QStyleOptionGraphicsItem *, QWidget *)
+ void drawItems(QPainter *, int, QGraphicsItem **, const QStyleOptionGraphicsItem *, QWidget *) override
{ ++drawCount; }
int drawCount;
};
@@ -4498,7 +4500,7 @@ void tst_QGraphicsView::compositionModeInDrawBackground()
painted(false), compositionMode(QPainter::CompositionMode_SourceOver) {}
bool painted;
QPainter::CompositionMode compositionMode;
- void drawBackground(QPainter *painter, const QRectF &)
+ void drawBackground(QPainter *painter, const QRectF &) override
{
compositionMode = painter->compositionMode();
painted = true;
@@ -4624,7 +4626,7 @@ void tst_QGraphicsView::task259503_scrollingArtifacts()
QRegion updateRegion;
bool itSTimeToTest;
- void paintEvent(QPaintEvent *event)
+ void paintEvent(QPaintEvent *event) override
{
QGraphicsView::paintEvent(event);
@@ -4713,7 +4715,7 @@ void tst_QGraphicsView::QTBUG_5859_exposedRect()
{
public:
CustomScene(const QRectF &rect) : QGraphicsScene(rect) { }
- void drawBackground(QPainter * /* painter */, const QRectF &rect)
+ void drawBackground(QPainter * /* painter */, const QRectF &rect) override
{ lastBackgroundExposedRect = rect; }
QRectF lastBackgroundExposedRect;
};
@@ -4723,7 +4725,7 @@ void tst_QGraphicsView::QTBUG_5859_exposedRect()
public:
CustomRectItem(const QRectF &rect) : QGraphicsRectItem(rect)
{ setFlag(QGraphicsItem::ItemUsesExtendedStyleOption); }
- void paint(QPainter * /* painter */, const QStyleOptionGraphicsItem *option, QWidget * /* widget */ = 0)
+ void paint(QPainter * /* painter */, const QStyleOptionGraphicsItem *option, QWidget * /* widget */ = 0) override
{ lastExposedRect = option->exposedRect; }
QRectF lastExposedRect;
};
@@ -4778,7 +4780,7 @@ public:
setAcceptHoverEvents(true);
}
- bool sceneEvent(QEvent *event)
+ bool sceneEvent(QEvent *event) override
{
if (!checkEvents) // ensures that we don't look at stray events before we are ready
return QGraphicsRectItem::sceneEvent(event);
@@ -4838,9 +4840,10 @@ public:
{
setFlag(QGraphicsItem::ItemIsFocusable, true);
setFlag(QGraphicsItem::ItemAcceptsInputMethod, true);
+ setPen(Qt::NoPen); // Avoid adding a half pixel border to the rect.
}
- QVariant inputMethodQuery(Qt::InputMethodQuery) const
+ QVariant inputMethodQuery(Qt::InputMethodQuery) const override
{
return mf;
}
diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.h b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.h
index ed16878ecb..42e9e6e2a3 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.h
+++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.h
@@ -34,7 +34,7 @@
// value to add/remove has to be obtained in test run using the actual style.
struct ExpectedValueDescription {
- Q_DECL_CONSTEXPR ExpectedValueDescription(int v = 0, int sbeta = 0, int sta = 0)
+ constexpr ExpectedValueDescription(int v = 0, int sbeta = 0, int sta = 0)
: value(v)
, scrollBarExtentsToAdd(sbeta)
, spacingsToAdd(sta)
@@ -55,7 +55,7 @@ struct ExpectedValueDescription {
// Describes how often the scroll bar width/height has to be added to/removed
// from the according side of the sceneRect.
struct ScrollBarCount {
- Q_DECL_CONSTEXPR ScrollBarCount(int l = 0, int t = 0, int r = 0, int b = 0 )
+ constexpr ScrollBarCount(int l = 0, int t = 0, int r = 0, int b = 0 )
: left(l)
, top(t)
, right(r)
diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview_2.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview_2.cpp
index 297e83421b..5c9134a3b0 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview_2.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview_2.cpp
@@ -49,7 +49,7 @@ static void _scrollBarRanges_addTestData(const QByteArray &style, bool styled)
const int viewWidth = 250;
const int viewHeight = 100;
- static Q_CONSTEXPR struct Data {
+ static constexpr struct Data {
const char *name;
QRectF sceneRect;
ScrollBarCount sceneRectOffsetFactors;
diff --git a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp
index 882aa8bcbd..4298cc3da7 100644
--- a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp
@@ -640,11 +640,11 @@ void tst_QGraphicsWidget::fontPropagatesResolveToChildren()
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
- QCOMPARE(font.resolve(), uint(QFont::StyleResolved));
- QCOMPARE(root->font().resolve(), uint(QFont::StyleResolved));
- QCOMPARE(child1->font().resolve(), uint(QFont::StyleResolved));
- QCOMPARE(child2->font().resolve(), uint(QFont::StyleResolved));
- QCOMPARE(child3->font().resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(font.resolveMask(), uint(QFont::StyleResolved));
+ QCOMPARE(root->font().resolveMask(), uint(QFont::StyleResolved));
+ QCOMPARE(child1->font().resolveMask(), uint(QFont::StyleResolved));
+ QCOMPARE(child2->font().resolveMask(), uint(QFont::StyleResolved));
+ QCOMPARE(child3->font().resolveMask(), uint(QFont::StyleResolved));
}
void tst_QGraphicsWidget::fontPropagatesResolveToGrandChildren()
@@ -675,12 +675,12 @@ void tst_QGraphicsWidget::fontPropagatesResolveToGrandChildren()
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
- QCOMPARE(font.resolve(), uint(QFont::StyleResolved));
- QCOMPARE(grandChild1->font().resolve(), uint(QFont::StyleResolved));
- QCOMPARE(grandChild2->font().resolve(), uint(QFont::StyleResolved));
- QCOMPARE(grandChild3->font().resolve(), uint(QFont::StyleResolved));
- QCOMPARE(grandChild4->font().resolve(), uint(QFont::StyleResolved));
- QCOMPARE(grandChild5->font().resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(font.resolveMask(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild1->font().resolveMask(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild2->font().resolveMask(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild3->font().resolveMask(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild4->font().resolveMask(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild5->font().resolveMask(), uint(QFont::StyleResolved));
}
void tst_QGraphicsWidget::fontPropagatesResolveViaNonWidget()
@@ -711,12 +711,12 @@ void tst_QGraphicsWidget::fontPropagatesResolveViaNonWidget()
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
- QCOMPARE(font.resolve(), uint(QFont::StyleResolved));
- QCOMPARE(grandChild1->font().resolve(), uint(QFont::StyleResolved));
- QCOMPARE(grandChild2->font().resolve(), uint(QFont::StyleResolved));
- QCOMPARE(grandChild3->font().resolve(), uint(QFont::StyleResolved));
- QCOMPARE(grandChild4->font().resolve(), uint(QFont::StyleResolved));
- QCOMPARE(grandChild5->font().resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(font.resolveMask(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild1->font().resolveMask(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild2->font().resolveMask(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild3->font().resolveMask(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild4->font().resolveMask(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild5->font().resolveMask(), uint(QFont::StyleResolved));
}
void tst_QGraphicsWidget::fontPropagatesResolveFromScene()
@@ -747,16 +747,16 @@ void tst_QGraphicsWidget::fontPropagatesResolveFromScene()
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
- QCOMPARE(font.resolve(), uint(QFont::StyleResolved));
- QCOMPARE(root->font().resolve(), uint(QFont::StyleResolved));
- QCOMPARE(child1->font().resolve(), uint(QFont::StyleResolved));
- QCOMPARE(child2->font().resolve(), uint(QFont::StyleResolved));
- QCOMPARE(child3->font().resolve(), uint(QFont::StyleResolved));
- QCOMPARE(grandChild1->font().resolve(), uint(QFont::StyleResolved));
- QCOMPARE(grandChild2->font().resolve(), uint(QFont::StyleResolved));
- QCOMPARE(grandChild3->font().resolve(), uint(QFont::StyleResolved));
- QCOMPARE(grandChild4->font().resolve(), uint(QFont::StyleResolved));
- QCOMPARE(grandChild5->font().resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(font.resolveMask(), uint(QFont::StyleResolved));
+ QCOMPARE(root->font().resolveMask(), uint(QFont::StyleResolved));
+ QCOMPARE(child1->font().resolveMask(), uint(QFont::StyleResolved));
+ QCOMPARE(child2->font().resolveMask(), uint(QFont::StyleResolved));
+ QCOMPARE(child3->font().resolveMask(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild1->font().resolveMask(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild2->font().resolveMask(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild3->font().resolveMask(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild4->font().resolveMask(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild5->font().resolveMask(), uint(QFont::StyleResolved));
}
void tst_QGraphicsWidget::fontPropagatesResolveInParentChange()
@@ -785,8 +785,8 @@ void tst_QGraphicsWidget::fontPropagatesResolveInParentChange()
QVERIFY(!grandChild2->font().italic());
QVERIFY(grandChild2->font().bold());
- QCOMPARE(grandChild1->font().resolve(), uint(QFont::StyleResolved));
- QCOMPARE(grandChild2->font().resolve(), uint(QFont::WeightResolved));
+ QCOMPARE(grandChild1->font().resolveMask(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild2->font().resolveMask(), uint(QFont::WeightResolved));
grandChild2->setParentItem(child1);
@@ -800,8 +800,8 @@ void tst_QGraphicsWidget::fontPropagatesResolveInParentChange()
QVERIFY(grandChild2->font().italic());
QVERIFY(!grandChild2->font().bold());
- QCOMPARE(grandChild1->font().resolve(), uint(QFont::StyleResolved));
- QCOMPARE(grandChild2->font().resolve(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild1->font().resolveMask(), uint(QFont::StyleResolved));
+ QCOMPARE(grandChild2->font().resolveMask(), uint(QFont::StyleResolved));
}
@@ -911,12 +911,12 @@ void tst_QGraphicsWidget::fontPropagationWidgetItemWidget()
widget->setFont(font);
QCOMPARE(widget2->font().pointSize(), 43);
- QCOMPARE(widget2->font().resolve(), uint(QFont::SizeResolved));
+ QCOMPARE(widget2->font().resolveMask(), uint(QFont::SizeResolved));
widget->setFont(QFont());
QCOMPARE(widget2->font().pointSize(), qApp->font().pointSize());
- QCOMPARE(widget2->font().resolve(), QFont().resolve());
+ QCOMPARE(widget2->font().resolveMask(), QFont().resolveMask());
}
void tst_QGraphicsWidget::fontPropagationSceneChange()
diff --git a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
index 02be27ffc7..5f98902abd 100644
--- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
+++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
@@ -196,13 +196,13 @@ class DialogItemDelegate : public QStyledItemDelegate
{
public:
using QStyledItemDelegate::QStyledItemDelegate;
- QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &) const
+ QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &) const override
{
openedEditor = new QDialog(parent);
return openedEditor;
}
- void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
+ void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override
{
Q_UNUSED(model);
Q_UNUSED(index);
@@ -516,8 +516,8 @@ void tst_QAbstractItemView::basic_tests(QAbstractItemView *view)
#if QT_CONFIG(draganddrop)
if (!view->model())
view->startDrag(Qt::CopyAction);
-
- view->viewOptions();
+ QStyleOptionViewItem option;
+ view->initViewItemOption(&option);
view->setState(QAbstractItemView::NoState);
QCOMPARE(view->state(), QAbstractItemView::NoState);
diff --git a/tests/auto/widgets/itemviews/qcolumnview/BLACKLIST b/tests/auto/widgets/itemviews/qcolumnview/BLACKLIST
new file mode 100644
index 0000000000..e20ee75eaa
--- /dev/null
+++ b/tests/auto/widgets/itemviews/qcolumnview/BLACKLIST
@@ -0,0 +1,3 @@
+# QTBUG-41341
+[scrollTo]
+macos
diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
index 3da8e344bd..ff76ddc39c 100644
--- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
@@ -104,7 +104,6 @@ class tst_QHeaderView : public QObject
public:
tst_QHeaderView();
- static void initMain();
private slots:
void initTestCase();
@@ -265,14 +264,6 @@ protected:
QElapsedTimer timer;
};
-void tst_QHeaderView::initMain()
-{
-#ifdef Q_OS_WIN
- // Ensure minimum size constraints of framed windows on High DPI screens
- QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
-#endif
-}
-
class QtTestModel: public QAbstractTableModel
{
Q_OBJECT
diff --git a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
index 36ab1a64a6..16f8b97d49 100644
--- a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
+++ b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
@@ -77,7 +77,7 @@ public:
void drawDisplay(QPainter *painter,
const QStyleOptionViewItem &option,
- const QRect &rect, const QString &text) const
+ const QRect &rect, const QString &text) const override
{
displayText = text;
displayFont = option.font;
@@ -86,7 +86,7 @@ public:
void drawDecoration(QPainter *painter,
const QStyleOptionViewItem &option,
- const QRect &rect, const QPixmap &pixmap) const
+ const QRect &rect, const QPixmap &pixmap) const override
{
decorationPixmap = pixmap;
decorationRect = rect;
@@ -113,7 +113,7 @@ public:
return QItemDelegate::rect(option, index, role);
}
- inline bool eventFilter(QObject *object, QEvent *event)
+ inline bool eventFilter(QObject *object, QEvent *event) override
{
return QItemDelegate::eventFilter(object, event);
}
@@ -121,7 +121,7 @@ public:
inline bool editorEvent(QEvent *event,
QAbstractItemModel *model,
const QStyleOptionViewItem &option,
- const QModelIndex &index)
+ const QModelIndex &index) override
{
return QItemDelegate::editorEvent(event, model, option, index);
}
@@ -149,19 +149,19 @@ public:
~TestItemModel() {}
- int rowCount(const QModelIndex &parent) const
+ int rowCount(const QModelIndex &parent) const override
{
Q_UNUSED(parent);
return 1;
}
- int columnCount(const QModelIndex &parent) const
+ int columnCount(const QModelIndex &parent) const override
{
Q_UNUSED(parent);
return 1;
}
- QVariant data(const QModelIndex& index, int role) const
+ QVariant data(const QModelIndex& index, int role) const override
{
Q_UNUSED(index);
static QPixmap pixmap(size);
@@ -812,7 +812,7 @@ void tst_QItemDelegate::dateTimeEditor()
class ChooseEditorDelegate : public QItemDelegate
{
public:
- virtual QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &o, const QModelIndex &i) const
+ virtual QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &o, const QModelIndex &i) const override
{
if (m_editor) {
m_editor->setParent(parent);
@@ -822,7 +822,7 @@ public:
return m_editor;
}
- virtual void destroyEditor(QWidget *editor, const QModelIndex &i) const
+ virtual void destroyEditor(QWidget *editor, const QModelIndex &i) const override
{ // This is a reimplementation of QAbstractItemDelegate::destroyEditor just set the variable m_editor to 0
// The only reason we do this is to avoid the not recommended direct delete of editor (destroyEditor uses deleteLater)
QItemDelegate::destroyEditor(editor, i); // Allow destroy
@@ -843,7 +843,9 @@ class FastEditItemView : public QTableView
public:
QWidget* fastEdit(const QModelIndex &i) // Consider this as QAbstractItemView::edit( )
{
- QWidget *v = itemDelegate()->createEditor(viewport(), viewOptions(), i);
+ QStyleOptionViewItem option;
+ initViewItemOption(&option);
+ QWidget *v = itemDelegate()->createEditor(viewport(), option, i);
if (v)
itemDelegate()->setEditorData(v, i);
return v;
@@ -1305,7 +1307,7 @@ void tst_QItemDelegate::enterKey()
struct TestDelegate : public QItemDelegate
{
WidgetType widgetType;
- virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& /*option*/, const QModelIndex& /*index*/) const
+ virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& /*option*/, const QModelIndex& /*index*/) const override
{
QWidget *editor = 0;
switch(widgetType) {
@@ -1454,7 +1456,7 @@ void tst_QItemDelegate::testLineEditValidation()
struct TestDelegate : public QItemDelegate
{
- virtual QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
+ virtual QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override
{
Q_UNUSED(option);
Q_UNUSED(index);
diff --git a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
index f5fcc35084..238f5f3ffe 100644
--- a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
+++ b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
@@ -84,7 +84,7 @@ public:
using QListView::setSelection;
using QListView::setViewportMargins;
using QListView::startDrag;
- using QListView::viewOptions;
+ using QListView::initViewItemOption;
QRegion getVisualRegionForSelection() const
{
return QListView::visualRegionForSelection(selectionModel()->selection());
@@ -2258,10 +2258,11 @@ void tst_QListView::testScrollToWithHidden()
void tst_QListView::testViewOptions()
{
PublicListView view;
- QStyleOptionViewItem options = view.viewOptions();
+ QStyleOptionViewItem options;
+ view.initViewItemOption(&options);
QCOMPARE(options.decorationPosition, QStyleOptionViewItem::Left);
view.setViewMode(QListView::IconMode);
- options = view.viewOptions();
+ view.initViewItemOption(&options);
QCOMPARE(options.decorationPosition, QStyleOptionViewItem::Top);
}
diff --git a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
index 8e2f5ba068..37f37eaac8 100644
--- a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+++ b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
@@ -257,7 +257,7 @@ public:
using QTableView::setSelection;
using QTableView::selectedIndexes;
using QTableView::sizeHintForRow;
- using QTableView::viewOptions;
+ using QTableView::initViewItemOption;
bool checkSignalOrder = false;
public slots:
@@ -384,6 +384,9 @@ private slots:
void sortingEnabled_data();
void sortingEnabled();
+ void sortByColumn_data();
+ void sortByColumn();
+
void scrollTo_data();
void scrollTo();
@@ -2681,6 +2684,64 @@ void tst_QTableView::sortingEnabled()
// QFETCH(int, columnCount);
}
+void tst_QTableView::sortByColumn_data()
+{
+ QTest::addColumn<bool>("sortingEnabled");
+ QTest::newRow("sorting enabled") << true;
+ QTest::newRow("sorting disabled") << false;
+}
+
+// Checks sorting and that sortByColumn also sets the sortIndicator
+void tst_QTableView::sortByColumn()
+{
+ QFETCH(bool, sortingEnabled);
+ QTableView view;
+ QStandardItemModel model(4, 2);
+ QSortFilterProxyModel sfpm; // default QStandardItemModel does not support 'unsorted' state
+ sfpm.setSourceModel(&model);
+ model.setItem(0, 0, new QStandardItem("b"));
+ model.setItem(1, 0, new QStandardItem("d"));
+ model.setItem(2, 0, new QStandardItem("c"));
+ model.setItem(3, 0, new QStandardItem("a"));
+ model.setItem(0, 1, new QStandardItem("e"));
+ model.setItem(1, 1, new QStandardItem("g"));
+ model.setItem(2, 1, new QStandardItem("h"));
+ model.setItem(3, 1, new QStandardItem("f"));
+
+ view.setSortingEnabled(sortingEnabled);
+ view.setModel(&sfpm);
+ view.show();
+
+ view.sortByColumn(1, Qt::DescendingOrder);
+ QCOMPARE(view.horizontalHeader()->sortIndicatorSection(), 1);
+ QCOMPARE(view.model()->data(view.model()->index(0, 0)).toString(), QString::fromLatin1("c"));
+ QCOMPARE(view.model()->data(view.model()->index(1, 0)).toString(), QString::fromLatin1("d"));
+ QCOMPARE(view.model()->data(view.model()->index(0, 1)).toString(), QString::fromLatin1("h"));
+ QCOMPARE(view.model()->data(view.model()->index(1, 1)).toString(), QString::fromLatin1("g"));
+
+ view.sortByColumn(0, Qt::AscendingOrder);
+ QCOMPARE(view.horizontalHeader()->sortIndicatorSection(), 0);
+ QCOMPARE(view.model()->data(view.model()->index(0, 0)).toString(), QString::fromLatin1("a"));
+ QCOMPARE(view.model()->data(view.model()->index(1, 0)).toString(), QString::fromLatin1("b"));
+ QCOMPARE(view.model()->data(view.model()->index(0, 1)).toString(), QString::fromLatin1("f"));
+ QCOMPARE(view.model()->data(view.model()->index(1, 1)).toString(), QString::fromLatin1("e"));
+
+ view.sortByColumn(-1, Qt::AscendingOrder);
+ QCOMPARE(view.horizontalHeader()->sortIndicatorSection(), -1);
+ QCOMPARE(view.model()->data(view.model()->index(0, 0)).toString(), QString::fromLatin1("b"));
+ QCOMPARE(view.model()->data(view.model()->index(1, 0)).toString(), QString::fromLatin1("d"));
+ QCOMPARE(view.model()->data(view.model()->index(0, 1)).toString(), QString::fromLatin1("e"));
+ QCOMPARE(view.model()->data(view.model()->index(1, 1)).toString(), QString::fromLatin1("g"));
+
+ // a new 'sortByColumn()' should do a re-sort (e.g. due to the data changed), QTBUG-86268
+ view.setModel(&model);
+ view.sortByColumn(0, Qt::AscendingOrder);
+ QCOMPARE(view.model()->data(view.model()->index(0, 0)).toString(), QString::fromLatin1("a"));
+ model.setItem(0, 0, new QStandardItem("x"));
+ view.sortByColumn(0, Qt::AscendingOrder);
+ QCOMPARE(view.model()->data(view.model()->index(0, 0)).toString(), QString::fromLatin1("b"));
+}
+
void tst_QTableView::scrollTo_data()
{
QTest::addColumn<QAbstractItemView::ScrollMode>("verticalScrollMode");
@@ -4523,7 +4584,8 @@ void tst_QTableView::taskQTBUG_10169_sizeHintForRow()
void tst_QTableView::viewOptions()
{
QtTestTableView view;
- QStyleOptionViewItem options = view.viewOptions();
+ QStyleOptionViewItem options;
+ view.initViewItemOption(&options);
QVERIFY(options.showDecorationSelected);
}
diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
index 0c9c3dc3ad..7a22128af3 100644
--- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
+++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
@@ -1069,7 +1069,7 @@ void tst_QTreeView::itemDelegateForColumnOrRow()
QVERIFY(!view.itemDelegateForRow(0));
QVERIFY(!view.itemDelegateForColumn(0));
- QCOMPARE(view.itemDelegate(QModelIndex()), defaultDelegate);
+ QCOMPARE(view.itemDelegateForIndex(QModelIndex()), defaultDelegate);
QStandardItemModel model;
for (int i = 0; i < 100; ++i) {
@@ -1085,26 +1085,26 @@ void tst_QTreeView::itemDelegateForColumnOrRow()
QVERIFY(!view.itemDelegateForRow(0));
QVERIFY(!view.itemDelegateForColumn(0));
- QCOMPARE(view.itemDelegate(QModelIndex()), defaultDelegate);
- QCOMPARE(view.itemDelegate(view.model()->index(0, 0)), defaultDelegate);
+ QCOMPARE(view.itemDelegateForIndex(QModelIndex()), defaultDelegate);
+ QCOMPARE(view.itemDelegateForIndex(view.model()->index(0, 0)), defaultDelegate);
QPointer<QAbstractItemDelegate> rowDelegate = new QStyledItemDelegate;
view.setItemDelegateForRow(0, rowDelegate);
QVERIFY(!rowDelegate->parent());
QCOMPARE(view.itemDelegateForRow(0), rowDelegate);
- QCOMPARE(view.itemDelegate(view.model()->index(0, 0)), rowDelegate);
- QCOMPARE(view.itemDelegate(view.model()->index(0, 1)), rowDelegate);
- QCOMPARE(view.itemDelegate(view.model()->index(1, 0)), defaultDelegate);
- QCOMPARE(view.itemDelegate(view.model()->index(1, 1)), defaultDelegate);
+ QCOMPARE(view.itemDelegateForIndex(view.model()->index(0, 0)), rowDelegate);
+ QCOMPARE(view.itemDelegateForIndex(view.model()->index(0, 1)), rowDelegate);
+ QCOMPARE(view.itemDelegateForIndex(view.model()->index(1, 0)), defaultDelegate);
+ QCOMPARE(view.itemDelegateForIndex(view.model()->index(1, 1)), defaultDelegate);
QPointer<QAbstractItemDelegate> columnDelegate = new QStyledItemDelegate;
view.setItemDelegateForColumn(1, columnDelegate);
QVERIFY(!columnDelegate->parent());
QCOMPARE(view.itemDelegateForColumn(1), columnDelegate);
- QCOMPARE(view.itemDelegate(view.model()->index(0, 0)), rowDelegate);
- QCOMPARE(view.itemDelegate(view.model()->index(0, 1)), rowDelegate); // row wins
- QCOMPARE(view.itemDelegate(view.model()->index(1, 0)), defaultDelegate);
- QCOMPARE(view.itemDelegate(view.model()->index(1, 1)), columnDelegate);
+ QCOMPARE(view.itemDelegateForIndex(view.model()->index(0, 0)), rowDelegate);
+ QCOMPARE(view.itemDelegateForIndex(view.model()->index(0, 1)), rowDelegate); // row wins
+ QCOMPARE(view.itemDelegateForIndex(view.model()->index(1, 0)), defaultDelegate);
+ QCOMPARE(view.itemDelegateForIndex(view.model()->index(1, 1)), columnDelegate);
view.setItemDelegateForRow(0, nullptr);
QVERIFY(!view.itemDelegateForRow(0));
@@ -2490,12 +2490,13 @@ void tst_QTreeView::spanningItems()
// size hint
// every second row is un-spanned
- QStyleOptionViewItem option = view.viewOptions();
+ QStyleOptionViewItem option;
+ view.initViewItemOption(&option);
int w = view.header()->sectionSizeHint(0);
for (int i = 0; i < model.rowCount(QModelIndex()); ++i) {
if (!view.isFirstColumnSpanned(i, QModelIndex())) {
QModelIndex index = model.index(i, 0, QModelIndex());
- w = qMax(w, view.itemDelegate(index)->sizeHint(option, index).width() + view.indentation());
+ w = qMax(w, view.itemDelegateForIndex(index)->sizeHint(option, index).width() + view.indentation());
}
}
QCOMPARE(view.sizeHintForColumn(0), w);
@@ -2851,6 +2852,14 @@ void tst_QTreeView::sortByColumn()
QCOMPARE(view.model()->data(view.model()->index(1, 0)).toString(), QString::fromLatin1("d"));
QCOMPARE(view.model()->data(view.model()->index(0, 1)).toString(), QString::fromLatin1("e"));
QCOMPARE(view.model()->data(view.model()->index(1, 1)).toString(), QString::fromLatin1("g"));
+
+ // a new 'sortByColumn()' should do a re-sort (e.g. due to the data changed), QTBUG-86268
+ view.setModel(&model);
+ view.sortByColumn(0, Qt::AscendingOrder);
+ QCOMPARE(view.model()->data(view.model()->index(0, 0)).toString(), QString::fromLatin1("a"));
+ model.setItem(0, 0, new QStandardItem("x"));
+ view.sortByColumn(0, Qt::AscendingOrder);
+ QCOMPARE(view.model()->data(view.model()->index(0, 0)).toString(), QString::fromLatin1("b"));
}
/*
diff --git a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp
index f7b1cfec65..25a7989c95 100644
--- a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp
+++ b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp
@@ -1776,7 +1776,10 @@ void tst_QTreeWidget::setData()
QCOMPARE(qvariant_cast<QTreeWidgetItem*>(args.at(0)), item);
QCOMPARE(qvariant_cast<int>(args.at(1)), j);
item->setIcon(j, icon);
- QCOMPARE(itemChangedSpy.count(), 0);
+ QCOMPARE(itemChangedSpy.count(), 1);
+ args = itemChangedSpy.takeFirst();
+ QCOMPARE(qvariant_cast<QTreeWidgetItem*>(args.at(0)), item);
+ QCOMPARE(qvariant_cast<int>(args.at(1)), j);
const QString toolTip = QLatin1String("toolTip ") + iS;
item->setToolTip(j, toolTip);
diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
index a62f6c5699..54a9499fbf 100644
--- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
@@ -414,7 +414,7 @@ static char **QString2cstrings(const QString &args)
{
static QByteArrayList cache;
- const auto &list = args.splitRef(' ');
+ const auto &list = QStringView{ args }.split(' ');
auto argarray = new char*[list.count() + 1];
int i = 0;
@@ -675,7 +675,7 @@ void tst_QApplication::quitOnLastWindowClosed()
bool quitApplicationTriggered = false;
auto quitSlot = [&quitApplicationTriggered] () {
quitApplicationTriggered = true;
- QCoreApplication::quit();
+ QCoreApplication::exit();
};
{
@@ -911,7 +911,7 @@ void tst_QApplication::libraryPaths()
int argc = 1;
QApplication app(argc, &argv0);
QString appDirPath = QCoreApplication::applicationDirPath();
- QString installPathPlugins = QLibraryInfo::location(QLibraryInfo::PluginsPath);
+ QString installPathPlugins = QLibraryInfo::path(QLibraryInfo::PluginsPath);
QStringList actual = QApplication::libraryPaths();
actual.sort();
@@ -939,7 +939,7 @@ void tst_QApplication::libraryPaths()
// this test doesn't work if KDE 4 is installed
QCOMPARE(count, 1); // before creating QApplication, only the PluginsPath is in the libraryPaths()
#endif
- QString installPathPlugins = QLibraryInfo::location(QLibraryInfo::PluginsPath);
+ QString installPathPlugins = QLibraryInfo::path(QLibraryInfo::PluginsPath);
QApplication::addLibraryPath(installPathPlugins);
qCDebug(lcTests) << "installPathPlugins" << installPathPlugins;
qCDebug(lcTests) << "After adding plugins path:" << QApplication::libraryPaths();
@@ -963,7 +963,7 @@ void tst_QApplication::libraryPaths()
qCDebug(lcTests) << "Initial library path:" << QCoreApplication::libraryPaths();
int count = QCoreApplication::libraryPaths().count();
- QString installPathPlugins = QLibraryInfo::location(QLibraryInfo::PluginsPath);
+ QString installPathPlugins = QLibraryInfo::path(QLibraryInfo::PluginsPath);
QCoreApplication::addLibraryPath(installPathPlugins);
qCDebug(lcTests) << "installPathPlugins" << installPathPlugins;
qCDebug(lcTests) << "After adding plugins path:" << QCoreApplication::libraryPaths();
@@ -1024,7 +1024,7 @@ void tst_QApplication::libraryPaths_qt_plugin_path_2()
// library path list should contain the default plus the one valid path
QStringList expected =
QStringList()
- << QLibraryInfo::location(QLibraryInfo::PluginsPath)
+ << QLibraryInfo::path(QLibraryInfo::PluginsPath)
<< QDir(QCoreApplication::applicationDirPath()).canonicalPath()
<< QDir(QDir::fromNativeSeparators(QString::fromLatin1(validPath))).canonicalPath();
@@ -1045,7 +1045,7 @@ void tst_QApplication::libraryPaths_qt_plugin_path_2()
// library path list should contain the default
QStringList expected =
QStringList()
- << QLibraryInfo::location(QLibraryInfo::PluginsPath)
+ << QLibraryInfo::path(QLibraryInfo::PluginsPath)
<< QCoreApplication::applicationDirPath();
QVERIFY(isPathListIncluded(QCoreApplication::libraryPaths(), expected));
@@ -1807,7 +1807,7 @@ class CustomStyle : public QProxyStyle
public:
CustomStyle() : QProxyStyle("Windows") { Q_ASSERT(!polished); }
~CustomStyle() { polished = 0; }
- void polish(QPalette &palette)
+ void polish(QPalette &palette) override
{
polished++;
palette.setColor(QPalette::Active, QPalette::Link, Qt::red);
@@ -1822,7 +1822,7 @@ class CustomStylePlugin : public QStylePlugin
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QStyleFactoryInterface" FILE "customstyle.json")
public:
- QStyle *create(const QString &) { return new CustomStyle; }
+ QStyle *create(const QString &) override { return new CustomStyle; }
};
Q_IMPORT_PLUGIN(CustomStylePlugin)
@@ -1836,7 +1836,7 @@ void tst_QApplication::applicationPalettePolish()
qputenv("QT_DESKTOP_STYLE_KEY", "customstyle");
QApplication app(argc, &argv0);
QVERIFY(CustomStyle::polished);
- QVERIFY(!app.palette().resolve());
+ QVERIFY(!app.palette().resolveMask());
QCOMPARE(app.palette().color(QPalette::Link), Qt::red);
qunsetenv("QT_DESKTOP_STYLE_KEY");
}
@@ -1846,7 +1846,7 @@ void tst_QApplication::applicationPalettePolish()
QApplication::setStyle(new CustomStyle);
QApplication app(argc, &argv0);
QVERIFY(CustomStyle::polished);
- QVERIFY(!app.palette().resolve());
+ QVERIFY(!app.palette().resolveMask());
QCOMPARE(app.palette().color(QPalette::Link), Qt::red);
}
@@ -1854,13 +1854,13 @@ void tst_QApplication::applicationPalettePolish()
QApplication app(argc, &argv0);
app.setStyle(new CustomStyle);
QVERIFY(CustomStyle::polished);
- QVERIFY(!app.palette().resolve());
+ QVERIFY(!app.palette().resolveMask());
QCOMPARE(app.palette().color(QPalette::Link), Qt::red);
CustomStyle::polished = 0;
app.setPalette(QPalette());
QVERIFY(CustomStyle::polished);
- QVERIFY(!app.palette().resolve());
+ QVERIFY(!app.palette().resolveMask());
QCOMPARE(app.palette().color(QPalette::Link), Qt::red);
CustomStyle::polished = 0;
@@ -1868,7 +1868,7 @@ void tst_QApplication::applicationPalettePolish()
palette.setColor(QPalette::Active, QPalette::Highlight, Qt::green);
app.setPalette(palette);
QVERIFY(CustomStyle::polished);
- QVERIFY(app.palette().resolve());
+ QVERIFY(app.palette().resolveMask());
QCOMPARE(app.palette().color(QPalette::Link), Qt::red);
QCOMPARE(app.palette().color(QPalette::Highlight), Qt::green);
}
diff --git a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp
index cbfbefaf3c..00e82248d4 100644
--- a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp
+++ b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp
@@ -71,7 +71,7 @@ public:
}
virtual int pixelMetric(PixelMetric metric, const QStyleOption * option = 0,
- const QWidget * widget = 0 ) const;
+ const QWidget * widget = 0 ) const override;
int hspacing;
int vspacing;
@@ -245,7 +245,7 @@ public:
}
virtual QRect subElementRect(SubElement sr, const QStyleOption *opt,
- const QWidget *widget) const
+ const QWidget *widget) const override
{
QRect rect = opt->rect;
switch (sr) {
@@ -411,14 +411,14 @@ class LayoutItem : public QLayoutItem
public:
LayoutItem(const Descr &descr) :m_descr(descr) {}
- QSize sizeHint() const { return QSize(m_descr.sizeHint, 100); }
- QSize minimumSize() const { return QSize(m_descr.minimumSize, 0); }
- QSize maximumSize() const { return QSize(m_descr.maximumSize, QLAYOUTSIZE_MAX); }
- Qt::Orientations expandingDirections() const
+ QSize sizeHint() const override { return QSize(m_descr.sizeHint, 100); }
+ QSize minimumSize() const override { return QSize(m_descr.minimumSize, 0); }
+ QSize maximumSize() const override { return QSize(m_descr.maximumSize, QLAYOUTSIZE_MAX); }
+ Qt::Orientations expandingDirections() const override
{ return m_descr.expanding ? Qt::Horizontal : Qt::Orientations{}; }
- void setGeometry(const QRect &r) { m_pos = r.x(); m_size = r.width();}
- QRect geometry() const { return QRect(m_pos, 0, m_size, 100); }
- bool isEmpty() const { return m_descr.empty; }
+ void setGeometry(const QRect &r) override { m_pos = r.x(); m_size = r.width();}
+ QRect geometry() const override { return QRect(m_pos, 0, m_size, 100); }
+ bool isEmpty() const override { return m_descr.empty; }
private:
Descr m_descr;
diff --git a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
index fd4ce89b56..06e82ecac8 100644
--- a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
+++ b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
@@ -52,7 +52,7 @@ using namespace QTestPrivate;
// ItemRole has enumerators for numerical values 0..2, thus the only
// valid numerical values for storing into an ItemRole variable are 0..3:
-Q_CONSTEXPR QFormLayout::ItemRole invalidRole = QFormLayout::ItemRole(3);
+constexpr QFormLayout::ItemRole invalidRole = QFormLayout::ItemRole(3);
struct QFormLayoutTakeRowResultHolder {
QFormLayoutTakeRowResultHolder(QFormLayout::TakeRowResult result) noexcept
@@ -298,7 +298,7 @@ public:
}
virtual int pixelMetric(PixelMetric metric, const QStyleOption * option = 0,
- const QWidget * widget = 0 ) const;
+ const QWidget * widget = 0 ) const override;
int hspacing;
int vspacing;
@@ -391,7 +391,7 @@ void tst_QFormLayout::contentsRect()
class DummyMacStyle : public QCommonStyle
{
public:
- virtual int styleHint ( StyleHint hint, const QStyleOption * option = 0, const QWidget * widget = 0, QStyleHintReturn * returnData = 0 ) const
+ virtual int styleHint ( StyleHint hint, const QStyleOption * option = 0, const QWidget * widget = 0, QStyleHintReturn * returnData = 0 ) const override
{
switch(hint) {
case SH_FormLayoutFormAlignment:
@@ -411,7 +411,7 @@ public:
class DummyQtopiaStyle : public QCommonStyle
{
public:
- virtual int styleHint ( StyleHint hint, const QStyleOption * option = 0, const QWidget * widget = 0, QStyleHintReturn * returnData = 0 ) const
+ virtual int styleHint ( StyleHint hint, const QStyleOption * option = 0, const QWidget * widget = 0, QStyleHintReturn * returnData = 0 ) const override
{
switch(hint) {
case SH_FormLayoutFormAlignment:
diff --git a/tests/auto/widgets/kernel/qgesturerecognizer/tst_qgesturerecognizer.cpp b/tests/auto/widgets/kernel/qgesturerecognizer/tst_qgesturerecognizer.cpp
index fa1bc3e57a..b65f6a5ff6 100644
--- a/tests/auto/widgets/kernel/qgesturerecognizer/tst_qgesturerecognizer.cpp
+++ b/tests/auto/widgets/kernel/qgesturerecognizer/tst_qgesturerecognizer.cpp
@@ -126,7 +126,7 @@ bool TestWidget::event(QEvent * event)
return QWidget::event(event);
}
-static void pressSequence(QTest::QTouchEventSequence &sequence, QList<QPoint> &points,
+static void pressSequence(QTest::QTouchEventWidgetSequence &sequence, QList<QPoint> &points,
QWidget *widget)
{
const int pointCount = points.size();
@@ -135,7 +135,7 @@ static void pressSequence(QTest::QTouchEventSequence &sequence, QList<QPoint> &p
sequence.commit();
}
-static void linearSequence(int n, const QPoint &delta, QTest::QTouchEventSequence &sequence,
+static void linearSequence(int n, const QPoint &delta, QTest::QTouchEventWidgetSequence &sequence,
QList<QPoint> &points, QWidget *widget)
{
const int pointCount = points.size();
@@ -148,7 +148,7 @@ static void linearSequence(int n, const QPoint &delta, QTest::QTouchEventSequenc
}
}
-static void releaseSequence(QTest::QTouchEventSequence &sequence, QList<QPoint> &points,
+static void releaseSequence(QTest::QTouchEventWidgetSequence &sequence, QList<QPoint> &points,
QWidget *widget)
{
const int pointCount = points.size();
@@ -188,7 +188,7 @@ void tst_QGestureRecognizer::panGesture()
for (int i = 0; i < panPoints; ++i)
points.append(QPoint(10 + i *20, 10 + i *20));
- QTest::QTouchEventSequence panSequence = QTest::touchEvent(&widget, m_touchDevice);
+ QTest::QTouchEventWidgetSequence panSequence = QTest::touchEvent(&widget, m_touchDevice);
pressSequence(panSequence, points, &widget);
linearSequence(5, QPoint(20, 20), panSequence, points, &widget);
releaseSequence(panSequence, points, &widget);
@@ -231,7 +231,7 @@ void tst_QGestureRecognizer::pinchGesture()
points.append(widget.rect().center());
points.append(points.front() + QPoint(0, 20));
- QTest::QTouchEventSequence pinchSequence = QTest::touchEvent(&widget, m_touchDevice);
+ QTest::QTouchEventWidgetSequence pinchSequence = QTest::touchEvent(&widget, m_touchDevice);
pressSequence(pinchSequence, points, &widget);
for (int s = 0; s < 5; ++s) {
@@ -288,7 +288,7 @@ void tst_QGestureRecognizer::swipeGesture()
for (int i = 0; i < swipePoints - 1; ++i)
points.append(fingerDistance + i * fingerDistance);
- QTest::QTouchEventSequence swipeSequence = QTest::touchEvent(&widget, m_touchDevice);
+ QTest::QTouchEventWidgetSequence swipeSequence = QTest::touchEvent(&widget, m_touchDevice);
pressSequence(swipeSequence, points, &widget);
// Press point #3
diff --git a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp
index 26dbab5e15..69d85df597 100644
--- a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp
+++ b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp
@@ -386,7 +386,7 @@ public:
SizeHinter(int w, int h, QWidget *parent = 0)
: QWidget(parent), sh(QSize(w,h)) {}
void setSizeHint(QSize s) { sh = s; }
- QSize sizeHint() const { return sh; }
+ QSize sizeHint() const override { return sh; }
private:
QSize sh;
};
@@ -452,7 +452,7 @@ public:
}
virtual int pixelMetric(PixelMetric metric, const QStyleOption * option = nullptr,
- const QWidget * widget = nullptr ) const;
+ const QWidget * widget = nullptr ) const override;
int spacing = 6;
int margin = 9;
@@ -508,11 +508,11 @@ public:
}
void setSizeHint(const QSize &s) { sh = s; }
- QSize sizeHint() const { return sh; }
+ QSize sizeHint() const override { return sh; }
void setMinimumSizeHint(const QSize &s) { msh = s; }
- QSize minimumSizeHint() const { return msh; }
+ QSize minimumSizeHint() const override { return msh; }
- virtual int heightForWidth(int width) const;
+ virtual int heightForWidth(int width) const override;
void setNumberOfPixels(int numPixels) {
m_numPixels = numPixels;
@@ -901,9 +901,9 @@ public:
}
virtual int pixelMetric(PixelMetric metric, const QStyleOption * option = 0,
- const QWidget * widget = 0 ) const;
+ const QWidget * widget = 0 ) const override;
virtual QRect subElementRect(SubElement sr, const QStyleOption *opt,
- const QWidget *widget) const;
+ const QWidget *widget) const override;
int hspacing;
int vspacing;
@@ -913,7 +913,7 @@ public:
QSizePolicy::ControlType control2,
Qt::Orientation orientation,
const QStyleOption *option = 0,
- const QWidget *widget = 0) const;
+ const QWidget *widget = 0) const override;
};
diff --git a/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp b/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp
index e5e0a48503..dec332196b 100644
--- a/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp
+++ b/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp
@@ -104,8 +104,8 @@ public:
void setSizeHint(const QSize &s) { sh = s; }
- QSize sizeHint() const { return sh; }
- QSize minimumSizeHint() const { return msh; }
+ QSize sizeHint() const override { return sh; }
+ QSize minimumSizeHint() const override { return msh; }
private:
QSize sh;
@@ -221,13 +221,13 @@ class MyLayout : public QLayout
{
public:
MyLayout() : invalidated(false) {}
- virtual void invalidate() {invalidated = true;}
+ virtual void invalidate() override {invalidated = true;}
bool invalidated;
- QSize sizeHint() const {return QSize();}
- void addItem(QLayoutItem*) {}
- QLayoutItem* itemAt(int) const {return 0;}
- QLayoutItem* takeAt(int) {return 0;}
- int count() const {return 0;}
+ QSize sizeHint() const override {return QSize();}
+ void addItem(QLayoutItem*) override {}
+ QLayoutItem* itemAt(int) const override {return 0;}
+ QLayoutItem* takeAt(int) override {return 0;}
+ int count() const override {return 0;}
};
void tst_QLayout::setContentsMargins()
@@ -253,7 +253,7 @@ void tst_QLayout::setContentsMargins()
class EventReceiver : public QObject
{
public:
- bool eventFilter(QObject *watched, QEvent *event)
+ bool eventFilter(QObject *watched, QEvent *event) override
{
if (event->type() == QEvent::Show) {
geom = static_cast<QWidget*>(watched)->geometry();
diff --git a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
index 903eab1a3f..2c07d6511b 100644
--- a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
+++ b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
@@ -323,11 +323,11 @@ void tst_QShortcut::number_data()
Shift + Qt::Key_Plus on Shift + Qt::Key_Pluss
Qt::Key_Plus on Shift + Qt::Key_Pluss
*/
- QTest::newRow("N002 - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::SHIFT + Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N002:Shift+M - [Shift+M]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_M) << int('M') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("N002 - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::SHIFT | Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N002:Shift+M - [Shift+M]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT | Qt::Key_M) << int('M') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
QTest::newRow("N002:M - [Shift+M]") << TestAccel << NoWidget << QString() << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N002 - slot2") << SetupAccel << TriggerSlot2 << QString() << int(Qt::SHIFT + Qt::Key_Plus) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N002:Shift++ [Shift++]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
+ QTest::newRow("N002 - slot2") << SetupAccel << TriggerSlot2 << QString() << int(Qt::SHIFT | Qt::Key_Plus) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N002:Shift++ [Shift++]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT | Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
QTest::newRow("N002:+ [Shift++]") << TestAccel << NoWidget << QString() << int(Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
QTest::newRow("N002 - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
@@ -345,8 +345,8 @@ void tst_QShortcut::number_data()
Qt::Key_F1 on Shift + Qt::Key_F1
*/
- QTest::newRow("N004 - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::SHIFT + Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N004:Shift+F1 - [Shift+F1]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("N004 - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::SHIFT | Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N004:Shift+F1 - [Shift+F1]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT | Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
QTest::newRow("N004:F1 - [Shift+F1]") << TestAccel << NoWidget << QString() << int(Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
QTest::newRow("N004 - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
@@ -362,7 +362,7 @@ void tst_QShortcut::number_data()
//QTest::newRow("N005a:Shift+Tab - [Tab]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
// (Shift+)BackTab != Tab, but Shift+BackTab == Shift+Tab
QTest::newRow("N005a:Backtab - [Tab]") << TestAccel << NoWidget << QString() << int(Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N005a:Shift+Backtab - [Tab]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N005a:Shift+Backtab - [Tab]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT | Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
QTest::newRow("N005a - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
/* Testing Single Sequences
@@ -371,11 +371,11 @@ void tst_QShortcut::number_data()
Qt::Key_Backtab on Shift + Qt::Key_Tab
Shift + Qt::Key_Backtab on Shift + Qt::Key_Tab
*/
- QTest::newRow("N005b - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::SHIFT + Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N005b - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::SHIFT | Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
QTest::newRow("N005b:Tab - [Shift+Tab]") << TestAccel << NoWidget << QString() << int(Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N005b:Shift+Tab - [Shift+Tab]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("N005b:Shift+Tab - [Shift+Tab]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT | Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
QTest::newRow("N005b:BackTab - [Shift+Tab]") << TestAccel << NoWidget << QString() << int(Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N005b:Shift+BackTab - [Shift+Tab]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("N005b:Shift+BackTab - [Shift+Tab]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT | Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
QTest::newRow("N005b - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
/* Testing Single Sequences
@@ -388,7 +388,7 @@ void tst_QShortcut::number_data()
QTest::newRow("N006a:Tab - [BackTab]") << TestAccel << NoWidget << QString() << int(Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
// This should work, since platform dependent code will transform the
// Shift+Tab into a Shift+BackTab, which should trigger the shortcut
- QTest::newRow("N006a:Shift+Tab - [BackTab]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; //XFAIL
+ QTest::newRow("N006a:Shift+Tab - [BackTab]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT | Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; //XFAIL
QTest::newRow("N006a:BackTab - [BackTab]") << TestAccel << NoWidget << QString() << int(Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
//commented out because the behaviour changed, those tests should be updated
//QTest::newRow("N006a:Shift+BackTab - [BackTab]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
@@ -400,11 +400,11 @@ void tst_QShortcut::number_data()
Qt::Key_Backtab on Shift + Qt::Key_Backtab
Shift + Qt::Key_Backtab on Shift + Qt::Key_Backtab
*/
- QTest::newRow("N006b - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::SHIFT + Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N006b - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::SHIFT | Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
QTest::newRow("N006b:Tab - [Shift+BackTab]") << TestAccel << NoWidget << QString() << int(Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N006b:Shift+Tab - [Shift+BackTab]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("N006b:Shift+Tab - [Shift+BackTab]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT | Qt::Key_Tab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
QTest::newRow("N006b:BackTab - [Shift+BackTab]") << TestAccel << NoWidget << QString() << int(Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N006b:Shift+BackTab - [Shift+BackTab]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; //XFAIL
+ QTest::newRow("N006b:Shift+BackTab - [Shift+BackTab]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT | Qt::Key_Backtab) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered; //XFAIL
QTest::newRow("N006b - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
//===========================================
@@ -417,9 +417,9 @@ void tst_QShortcut::number_data()
Shift + Qt::Key_F1
*/
QTest::newRow("N007 - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N007 - slot2") << SetupAccel << TriggerSlot2 << QString() << int(Qt::SHIFT + Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N007 - slot2") << SetupAccel << TriggerSlot2 << QString() << int(Qt::SHIFT | Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
QTest::newRow("N007:F1") << TestAccel << NoWidget << QString() << int(Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("N007:Shift + F1") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
+ QTest::newRow("N007:Shift + F1") << TestAccel << NoWidget << QString() << int(Qt::SHIFT | Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
QTest::newRow("N007 - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
/* Testing Single Sequences
@@ -429,13 +429,13 @@ void tst_QShortcut::number_data()
Alt + Qt::Key_M
*/
QTest::newRow("N01 - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N02 - slot2") << SetupAccel << TriggerSlot2 << QString() << int(Qt::SHIFT + Qt::Key_M) << int('M') << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N03 - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::CTRL + Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N04 - slot2") << SetupAccel << TriggerSlot2 << QString() << int(Qt::ALT + Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N02 - slot2") << SetupAccel << TriggerSlot2 << QString() << int(Qt::SHIFT | Qt::Key_M) << int('M') << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N03 - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::CTRL | Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N04 - slot2") << SetupAccel << TriggerSlot2 << QString() << int(Qt::ALT | Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
QTest::newRow("N:Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("N:Shift+Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_M) << int('M') << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
- QTest::newRow("N:Ctrl+Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::CTRL + Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("N:Alt+Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::ALT + Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
+ QTest::newRow("N:Shift+Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::SHIFT | Qt::Key_M) << int('M') << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
+ QTest::newRow("N:Ctrl+Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::CTRL | Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("N:Alt+Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::ALT | Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
/* Testing Single Sequence Ambiguity
Qt::Key_M on shortcut2
@@ -450,13 +450,13 @@ void tst_QShortcut::number_data()
Qt::Key_K
*/
QTest::newRow("N06 - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::Key_Aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N07 - slot2") << SetupAccel << TriggerSlot2 << QString() << int(Qt::SHIFT+Qt::Key_Aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N07 - slot2") << SetupAccel << TriggerSlot2 << QString() << int(Qt::SHIFT | Qt::Key_Aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
QTest::newRow("N08 - slot2") << SetupAccel << TriggerSlot1 << QString() << int(Qt::Key_K) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
QTest::newRow("N:Qt::Key_aring") << TestAccel << NoWidget << QString() << int(Qt::Key_Aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("N:Qt::Key_Aring") << TestAccel << NoWidget << QString() << int(Qt::SHIFT+Qt::Key_Aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
+ QTest::newRow("N:Qt::Key_Aring") << TestAccel << NoWidget << QString() << int(Qt::SHIFT | Qt::Key_Aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
QTest::newRow("N:Qt::Key_aring - Text Form") << TestAccel << NoWidget << QString() << 0 << 0xC5 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("N:Qt::Key_Aring - Text Form") << TestAccel << NoWidget << QString() << int(Qt::SHIFT+0) << 0xC5 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
+ QTest::newRow("N:Qt::Key_Aring - Text Form") << TestAccel << NoWidget << QString() << int(Qt::SHIFT) << 0xC5 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
QTest::newRow("N:Qt::Qt::Key_K") << TestAccel << NoWidget << QString() << int(Qt::Key_K) << int('k') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
QTest::newRow("N09 - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
@@ -467,11 +467,11 @@ void tst_QShortcut::number_data()
*/
QTest::newRow("N10 - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
QTest::newRow("N11 - slot2") << SetupAccel << TriggerSlot2 << QString() << int(Qt::Key_I) << 0 << int(Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("N12 - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::SHIFT + Qt::Key_I) << 0 << int(Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << NoResult;
+ QTest::newRow("N12 - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::SHIFT | Qt::Key_I) << 0 << int(Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << NoResult;
QTest::newRow("N:Qt::Key_M (2)") << TestAccel << NoWidget << QString() << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
QTest::newRow("N:Qt::Key_I, Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::Key_I) << int('i') << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << Slot2Triggered;
- QTest::newRow("N:Shift+Qt::Key_I, Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_I) << int('I') << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("N:Shift+Qt::Key_I, Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::SHIFT | Qt::Key_I) << int('I') << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << Slot1Triggered;
QTest::newRow("N:end") << TestEnd << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
}
@@ -513,10 +513,10 @@ void tst_QShortcut::text_data()
Ctrl + Qt::Key_Plus on Ctrl + Qt::Key_Pluss
*/
QTest::newRow("T002 - slot1") << SetupAccel << TriggerSlot1 << QString("Shift+M") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("T002:Shift+M - [Shift+M]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_M) << int('M') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("T002:Shift+M - [Shift+M]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT | Qt::Key_M) << int('M') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
QTest::newRow("T002:M - [Shift+M]") << TestAccel << NoWidget << QString() << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
QTest::newRow("T002 - slot2") << SetupAccel << TriggerSlot2 << QString("Shift++") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("T002:Shift++ [Shift++]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
+ QTest::newRow("T002:Shift++ [Shift++]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT | Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
QTest::newRow("T002:+ [Shift++]") << TestAccel << NoWidget << QString() << int(Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
QTest::newRow("T002 - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
@@ -528,7 +528,7 @@ void tst_QShortcut::text_data()
QTest::newRow("T002b - slot1") << SetupAccel << TriggerSlot1 << QString("Ctrl++") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
//commented out because the behaviour changed, those tests should be updated
//QTest::newRow("T002b:Shift+Ctrl++ [Ctrl++]")<< TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::CTRL + Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("T002b:Ctrl++ [Ctrl++]") << TestAccel << NoWidget << QString() << int(Qt::CTRL + Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("T002b:Ctrl++ [Ctrl++]") << TestAccel << NoWidget << QString() << int(Qt::CTRL | Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
QTest::newRow("T002b:+ [Ctrl++]") << TestAccel << NoWidget << QString() << int(Qt::Key_Plus) << int('+') << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
QTest::newRow("T002b - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
@@ -547,7 +547,7 @@ void tst_QShortcut::text_data()
Qt::Key_F1 on Shift + Qt::Key_F1
*/
QTest::newRow("T004 - slot1") << SetupAccel << TriggerSlot1 << QString("Shift+F1") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
- QTest::newRow("T004:Shift+F1 - [Shift+F1]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("T004:Shift+F1 - [Shift+F1]") << TestAccel << NoWidget << QString() << int(Qt::SHIFT | Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
QTest::newRow("T004:F1 - [Shift+F1]") << TestAccel << NoWidget << QString() << int(Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
QTest::newRow("T004 - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
@@ -563,7 +563,7 @@ void tst_QShortcut::text_data()
QTest::newRow("T007 - slot1") << SetupAccel << TriggerSlot1 << QString("F1") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
QTest::newRow("T007 - slot2") << SetupAccel << TriggerSlot2 << QString("Shift+F1") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
QTest::newRow("T007:F1") << TestAccel << NoWidget << QString() << int(Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("T007:Shift + F1") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
+ QTest::newRow("T007:Shift + F1") << TestAccel << NoWidget << QString() << int(Qt::SHIFT | Qt::Key_F1) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
QTest::newRow("T007 - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
/* Testing Single Sequences
@@ -578,9 +578,9 @@ void tst_QShortcut::text_data()
QTest::newRow("T04 - slot2") << SetupAccel << TriggerSlot2 << QString("Alt+M") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
QTest::newRow("T:Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("T:Shift + Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_M) << int('M') << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
- QTest::newRow("T:Ctrl + Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::CTRL + Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("T:Alt + Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::ALT + Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
+ QTest::newRow("T:Shift + Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::SHIFT | Qt::Key_M) << int('M') << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
+ QTest::newRow("T:Ctrl + Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::CTRL | Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("T:Alt + Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::ALT | Qt::Key_M) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
/* Testing Single Sequence Ambiguity
Qt::Key_M on shortcut2
@@ -599,9 +599,9 @@ void tst_QShortcut::text_data()
QTest::newRow("T07 - slot2") << SetupAccel << TriggerSlot2 << QString::fromLatin1("Shift+\x0C5")<< 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
QTest::newRow("T08 - slot2") << SetupAccel << TriggerSlot1 << QString("K") << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
QTest::newRow("T:Qt::Key_aring") << TestAccel << NoWidget << QString() << int(Qt::Key_Aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("T:Qt::Key_Aring") << TestAccel << NoWidget << QString() << int(Qt::SHIFT+Qt::Key_Aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
+ QTest::newRow("T:Qt::Key_Aring") << TestAccel << NoWidget << QString() << int(Qt::SHIFT | Qt::Key_Aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
QTest::newRow("T:Qt::Key_aring - Text Form") << TestAccel << NoWidget << QString() << 0 << 0xC5 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
- QTest::newRow("T:Qt::Key_Aring - Text Form") << TestAccel << NoWidget << QString() << int(Qt::SHIFT+0) << 0xC5 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
+ QTest::newRow("T:Qt::Key_Aring - Text Form") << TestAccel << NoWidget << QString() << int(Qt::SHIFT) << 0xC5 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
QTest::newRow("T:Qt::Key_K") << TestAccel << NoWidget << QString() << int(Qt::Key_K) << int('k') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
QTest::newRow("T09 - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
@@ -615,7 +615,7 @@ void tst_QShortcut::text_data()
QTest::newRow("T12 - slot1") << SetupAccel << TriggerSlot1 << QString("Shift+I, M")<< 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
QTest::newRow("T:Qt::Key_M (2)") << TestAccel << NoWidget << QString() << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
QTest::newRow("T:Qt::Key_I, Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::Key_I) << int('i') << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << Slot2Triggered;
- QTest::newRow("T:Shift+Qt::Key_I, Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::SHIFT + Qt::Key_I) << int('I') << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << Slot1Triggered;
+ QTest::newRow("T:Shift+Qt::Key_I, Qt::Key_M") << TestAccel << NoWidget << QString() << int(Qt::SHIFT | Qt::Key_I) << int('I') << int(Qt::Key_M) << int('m') << 0 << 0 << 0 << 0 << Slot1Triggered;
QTest::newRow("T:end") << TestEnd << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
}
@@ -671,7 +671,7 @@ void tst_QShortcut::disabledItems()
// Setup two identical shortcuts on different pushbuttons
auto pb1 = mainW.pushButton1();
auto pb2 = mainW.pushButton2();
- const int shiftM = Qt::SHIFT + Qt::Key_M;
+ const int shiftM = Qt::SHIFT | Qt::Key_M;
QShortcut *cut1 = setupShortcut(pb1, "shortcut1-pb1", TriggerSlot1,
QKeySequence(Qt::Key_M));
QShortcut *cut2 = setupShortcut(pb1, "shortcut2-pb1", TriggerSlot1,
@@ -715,7 +715,7 @@ void tst_QShortcut::disabledItems()
Shift + Qt::Key_F5 on slot2 (disabled)
*/
qDeleteAll(mainW.findChildren<QShortcut *>());
- const int shiftF5 = Qt::SHIFT + Qt::Key_F5;
+ const int shiftF5 = Qt::SHIFT | Qt::Key_F5;
cut1 = setupShortcut(pb1, "shortcut1-pb1", TriggerSlot1, QKeySequence(Qt::Key_F5));
cut4 = setupShortcut(pb2, "shortcut4-pb2", TriggerSlot2, QKeySequence(shiftF5));
@@ -754,7 +754,7 @@ void tst_QShortcut::ambiguousRotation()
Ctrl + Qt::Key_A on slot6
Ctrl + Qt::Key_A on slot7 (disabled)
*/
- const int ctrlA = Qt::CTRL + Qt::Key_A;
+ const int ctrlA = Qt::CTRL | Qt::Key_A;
QKeySequence ctrlA_Sequence(ctrlA);
QShortcut *cut1 = setupShortcut(&mainW, name, TriggerSlot1, ctrlA_Sequence);
QShortcut *cut2 = setupShortcut(&mainW, name, TriggerSlot2, ctrlA_Sequence);
@@ -940,12 +940,12 @@ void tst_QShortcut::unicodeCompare()
auto pb2 = mainW.pushButton2();
QKeySequence ks1("Ctrl+M"); // Unicode
- QKeySequence ks2(Qt::CTRL+Qt::Key_M); // non-Unicode
+ QKeySequence ks2(Qt::CTRL | Qt::Key_M); // non-Unicode
setupShortcut(pb1, "shortcut1-pb1", TriggerSlot1, ks1);
setupShortcut(pb2, "shortcut2-pb2", TriggerSlot2, ks2);
currentResult = NoResult;
- sendKeyEvents(&mainW, Qt::CTRL + Qt::Key_M);
+ sendKeyEvents(&mainW, Qt::CTRL | Qt::Key_M);
QCOMPARE( currentResult, Ambiguous );
// They _are_ ambiguous, so the QKeySequence operator==
// should indicate the same
@@ -968,7 +968,7 @@ void tst_QShortcut::keypressConsumption()
QVERIFY(QTest::qWaitForWindowActive(&mainW));
auto edit = mainW.testEdit();
- const int ctrlI = Qt::CTRL + Qt::Key_I;
+ const int ctrlI = Qt::CTRL | Qt::Key_I;
QShortcut *cut1 = setupShortcut(edit, "shortcut1-line", TriggerSlot1, QKeySequence(ctrlI, Qt::Key_A));
QShortcut *cut2 = setupShortcut(edit, "shortcut1-line", TriggerSlot2, QKeySequence(ctrlI, Qt::Key_B));
@@ -1001,7 +1001,7 @@ void tst_QShortcut::keypressConsumption()
// Make sure keypresses is passed on, since all multiple keysequences
// with Ctrl+I are disabled
- sendKeyEvents(edit, Qt::CTRL + Qt::Key_I); // Send key to edit
+ sendKeyEvents(edit, Qt::CTRL | Qt::Key_I); // Send key to edit
QCOMPARE( currentResult, NoResult );
QCOMPARE( ambigResult, NoResult );
QVERIFY(edit->toPlainText().endsWith("<Ctrl+I>"));
@@ -1015,9 +1015,9 @@ void tst_QShortcut::keypressConsumption()
edit->clear();
QCOMPARE(edit->toPlainText().size(), 0);
- auto cut = setupShortcut(edit, QLatin1String("first"), QKeySequence(Qt::CTRL + Qt::Key_A));
+ auto cut = setupShortcut(edit, QLatin1String("first"), QKeySequence(Qt::CTRL | Qt::Key_A));
connect(cut, &QShortcut::activated, edit, [this, edit] () {
- this->sendKeyEvents(edit, Qt::CTRL + Qt::Key_B);
+ this->sendKeyEvents(edit, Qt::CTRL | Qt::Key_B);
this->currentResult = tst_QShortcut::SentKeyEvent;
});
@@ -1025,7 +1025,7 @@ void tst_QShortcut::keypressConsumption()
// of shortcut processing.
currentResult = NoResult;
ambigResult = NoResult;
- sendKeyEvents(edit, Qt::CTRL + Qt::Key_A);
+ sendKeyEvents(edit, Qt::CTRL | Qt::Key_A);
QCOMPARE(currentResult, SentKeyEvent);
QCOMPARE(ambigResult, NoResult);
QCOMPARE(edit->toPlainText(), QLatin1String("<Ctrl+B>"));
@@ -1081,7 +1081,7 @@ void tst_QShortcut::context()
other2->clear();
QCOMPARE(QApplication::focusWidget(), static_cast<QWidget *>(other1));
- sendKeyEvents(other1, Qt::ALT+Qt::Key_1);
+ sendKeyEvents(other1, Qt::ALT | Qt::Key_1);
QCOMPARE(currentResult, Slot1Triggered);
QCOMPARE(ambigResult, NoResult);
QCOMPARE(edit->toPlainText(), QString());
@@ -1095,7 +1095,7 @@ void tst_QShortcut::context()
other1->clear();
other2->clear();
- sendKeyEvents(other1, Qt::ALT+Qt::Key_2);
+ sendKeyEvents(other1, Qt::ALT | Qt::Key_2);
QCOMPARE(currentResult, NoResult);
QCOMPARE(ambigResult, NoResult);
QCOMPARE(edit->toPlainText(), QString());
@@ -1109,7 +1109,7 @@ void tst_QShortcut::context()
other1->clear();
other2->clear();
- sendKeyEvents(other1, Qt::ALT+Qt::Key_3);
+ sendKeyEvents(other1, Qt::ALT | Qt::Key_3);
QCOMPARE(currentResult, Slot3Triggered);
QCOMPARE(ambigResult, NoResult);
QCOMPARE(edit->toPlainText(), QString());
@@ -1128,7 +1128,7 @@ void tst_QShortcut::context()
other1->clear();
other2->clear();
- sendKeyEvents(other2, Qt::ALT+Qt::Key_2);
+ sendKeyEvents(other2, Qt::ALT | Qt::Key_2);
QCOMPARE(currentResult, Slot2Triggered);
QCOMPARE(ambigResult, NoResult);
QCOMPARE(edit->toPlainText(), QString());
@@ -1313,7 +1313,7 @@ void tst_QShortcut::shortcutToFocusProxy()
completer.setModel(slm);
completer.setCompletionMode(QCompleter::PopupCompletion);
le.setCompleter(&completer);
- QShortcut *shortcut = new QShortcut(QKeySequence(Qt::ALT + Qt::Key_S), &le);
+ QShortcut *shortcut = new QShortcut(QKeySequence(Qt::ALT | Qt::Key_S), &le);
QObject::connect(shortcut, &QShortcut::activated, &le, &QLineEdit::clear);
le.setFocus();
le.show();
diff --git a/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp b/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp
index 89bb946be9..d307d9f9a8 100644
--- a/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp
+++ b/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp
@@ -111,20 +111,20 @@ void tst_QSizePolicy::constExpr()
/* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54922 */
#if !defined(Q_CC_GNU) || defined(Q_CC_INTEL) || defined(Q_CC_CLANG) || Q_CC_GNU >= 408
// check that certain ctors are constexpr (compile-only):
- { Q_CONSTEXPR QSizePolicy sp; Q_UNUSED(sp); }
- { Q_CONSTEXPR QSizePolicy sp = QSizePolicy(); Q_UNUSED(sp); }
- { Q_CONSTEXPR QSizePolicy sp = QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); Q_UNUSED(sp); }
- { Q_CONSTEXPR QSizePolicy sp = QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding, QSizePolicy::DefaultType);
- Q_CONSTEXPR QSizePolicy tp = sp.transposed(); Q_UNUSED(tp); }
+ { constexpr QSizePolicy sp; Q_UNUSED(sp); }
+ { constexpr QSizePolicy sp = QSizePolicy(); Q_UNUSED(sp); }
+ { constexpr QSizePolicy sp = QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); Q_UNUSED(sp); }
+ { constexpr QSizePolicy sp = QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding, QSizePolicy::DefaultType);
+ constexpr QSizePolicy tp = sp.transposed(); Q_UNUSED(tp); }
{
// QTBUG-69983: For ControlType != QSizePolicy::DefaultType, qCountTrailingZeroBits()
// is used, which MSVC 15.8.1 does not consider constexpr due to built-ins
# if defined(QT_HAS_CONSTEXPR_BUILTINS) && (!defined(Q_CC_MSVC) || _MSC_VER < 1915)
- Q_RELAXED_CONSTEXPR auto sp = QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed, QSizePolicy::CheckBox);
+ constexpr auto sp = QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed, QSizePolicy::CheckBox);
# else
- Q_CONSTEXPR auto sp = QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding, QSizePolicy::DefaultType);
+ constexpr auto sp = QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding, QSizePolicy::DefaultType);
# endif
- Q_RELAXED_CONSTEXPR auto tp = sp.transposed(); Q_UNUSED(tp);
+ constexpr auto tp = sp.transposed(); Q_UNUSED(tp);
}
#else
QSKIP("QSizePolicy cannot be constexpr with this version of the compiler.");
diff --git a/tests/auto/widgets/kernel/qstackedlayout/tst_qstackedlayout.cpp b/tests/auto/widgets/kernel/qstackedlayout/tst_qstackedlayout.cpp
index 053dc03296..8721a7191a 100644
--- a/tests/auto/widgets/kernel/qstackedlayout/tst_qstackedlayout.cpp
+++ b/tests/auto/widgets/kernel/qstackedlayout/tst_qstackedlayout.cpp
@@ -284,13 +284,13 @@ protected:
return true;
}
- void focusInEvent(QFocusEvent *event)
+ void focusInEvent(QFocusEvent *event) override
{
QLineEdit::focusInEvent(event);
hasFakeEditFocus = isSingleFocusWidget();
}
- void focusOutEvent(QFocusEvent *event)
+ void focusOutEvent(QFocusEvent *event) override
{
hasFakeEditFocus = false;
QLineEdit::focusOutEvent(event);
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index 6e304f2152..5f73864f99 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -196,6 +196,7 @@ private slots:
void activation();
#endif
void reparent();
+ void setScreen();
void windowState();
void showMaximized();
void showFullScreen();
@@ -2943,6 +2944,29 @@ void tst_QWidget::reparent()
QTRY_COMPARE(childTLW.pos(), tlwPos);
}
+void tst_QWidget::setScreen()
+{
+ const auto screens = QApplication::screens();
+ if (screens.count() < 2)
+ QSKIP("This test tests nothing on a machine with a single screen.");
+
+ QScreen *screen0 = screens.at(0);
+ QScreen *screen1 = screens.at(1);
+
+ QWidget window;
+ window.setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
+ window.setScreen(screen0);
+ QCOMPARE(window.screen(), screen0);
+ window.setScreen(screen1);
+ QCOMPARE(window.screen(), screen1);
+
+ // calling setScreen on a widget that is not a window does nothing
+ QWidget child(&window);
+ const QScreen *childScreen = child.screen();
+ child.setScreen(childScreen == screen0 ? screen1 : screen0);
+ QCOMPARE(child.screen(), childScreen);
+}
+
// Qt/Embedded does it differently.
void tst_QWidget::icon()
{
@@ -3578,7 +3602,7 @@ protected:
static QPixmap grabFromWidget(QWidget *w, const QRect &rect)
{
QPixmap pixmap = w->grab(rect);
- const qreal devicePixelRatio = pixmap.devicePixelRatioF();
+ const qreal devicePixelRatio = pixmap.devicePixelRatio();
if (!qFuzzyCompare(devicePixelRatio, qreal(1))) {
pixmap = pixmap.scaled((QSizeF(pixmap.size()) / devicePixelRatio).toSize(),
Qt::KeepAspectRatio, Qt::SmoothTransformation);
@@ -5572,7 +5596,7 @@ public:
r = QRegion();
}
- void enterEvent(QEvent *) override { ++enters; }
+ void enterEvent(QEnterEvent *) override { ++enters; }
void leaveEvent(QEvent *) override { ++leaves; }
void resetCounts()
@@ -5614,7 +5638,7 @@ bool verifyColor(QWidget &child, const QRegion &region, const QColor &color, int
const QPixmap pixmap = grabBackingStore
? child.grab(rect)
: grabWindow(window, rect.left(), rect.top(), rect.width(), rect.height());
- const QSize actualSize = pixmap.size() / pixmap.devicePixelRatioF();
+ const QSize actualSize = pixmap.size() / pixmap.devicePixelRatio();
if (!QTest::qCompare(actualSize, rect.size(), "pixmap.size()", "rect.size()", __FILE__, callerLine))
return false;
QPixmap expectedPixmap(pixmap); /* ensure equal formats */
@@ -6962,7 +6986,7 @@ public:
}
protected:
- void paintEvent(QPaintEvent *)
+ void paintEvent(QPaintEvent *) override
{
if (ellipse) {
QPainter painter(this);
@@ -8756,7 +8780,7 @@ public:
void resizeEvent(QResizeEvent *) override
{
- setMask(QRegion(QRect(0, 0, width(), 10).normalized()));
+ setMask(QRegion(QRect(0, 0, width(), 10)));
}
QRegion paintedRegion;
@@ -9246,8 +9270,8 @@ void tst_QWidget::translucentWidget()
widgetSnapshot = label.grab(QRect(QPoint(0, 0), label.size()));
#endif
const QImage actual = widgetSnapshot.toImage().convertToFormat(QImage::Format_RGB32);
- QImage expected = pm.toImage().scaled(label.devicePixelRatioF() * pm.size());
- expected.setDevicePixelRatio(label.devicePixelRatioF());
+ QImage expected = pm.toImage().scaled(label.devicePixelRatio() * pm.size());
+ expected.setDevicePixelRatio(label.devicePixelRatio());
QCOMPARE(actual.size(),expected.size());
QCOMPARE(actual,expected);
@@ -9264,7 +9288,7 @@ class MaskResizeTestWidget : public QWidget
public:
explicit MaskResizeTestWidget(QWidget* p = nullptr) : QWidget(p)
{
- setMask(QRegion(QRect(0, 0, 100, 100).normalized()));
+ setMask(QRegion(QRect(0, 0, 100, 100)));
}
void paintEvent(QPaintEvent* event) override
@@ -9280,12 +9304,12 @@ public:
public slots:
void enlargeMask() {
- QRegion newMask(QRect(0, 0, 150, 150).normalized());
+ QRegion newMask(QRect(0, 0, 150, 150));
setMask(newMask);
}
void shrinkMask() {
- QRegion newMask(QRect(0, 0, 50, 50).normalized());
+ QRegion newMask(QRect(0, 0, 50, 50));
setMask(newMask);
}
@@ -9603,7 +9627,7 @@ void tst_QWidget::syntheticEnterLeave()
{
public:
using QWidget::QWidget;
- void enterEvent(QEvent *) override { ++numEnterEvents; }
+ void enterEvent(QEnterEvent *) override { ++numEnterEvents; }
void leaveEvent(QEvent *) override { ++numLeaveEvents; }
int numEnterEvents = 0;
int numLeaveEvents = 0;
@@ -9718,7 +9742,7 @@ void tst_QWidget::taskQTBUG_4055_sendSyntheticEnterLeave()
{
public:
using QWidget::QWidget;
- void enterEvent(QEvent *) override { ++numEnterEvents; }
+ void enterEvent(QEnterEvent *) override { ++numEnterEvents; }
void mouseMoveEvent(QMouseEvent *event) override
{
QCOMPARE(event->button(), Qt::NoButton);
@@ -10118,7 +10142,7 @@ void tst_QWidget::focusProxy()
int focusOutCount = 0;
protected:
- bool eventFilter(QObject *receiver, QEvent *event)
+ bool eventFilter(QObject *receiver, QEvent *event) override
{
if (receiver == edit) {
switch (event->type()) {
diff --git a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp
index 890a53541a..17b119410f 100644
--- a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp
+++ b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp
@@ -523,10 +523,10 @@ public:
: QWidget(w), m_log(log), m_ignoreDragMove(ignoreDragMove)
{}
protected:
- void dragEnterEvent(QDragEnterEvent *);
- void dragMoveEvent(QDragMoveEvent *);
- void dragLeaveEvent(QDragLeaveEvent *);
- void dropEvent(QDropEvent *);
+ void dragEnterEvent(QDragEnterEvent *) override;
+ void dragMoveEvent(QDragMoveEvent *) override;
+ void dragLeaveEvent(QDragLeaveEvent *) override;
+ void dropEvent(QDropEvent *) override;
private:
void formatDropEvent(const char *function, const QDropEvent *e, QTextStream &str) const;
@@ -700,7 +700,7 @@ public:
DnDEventRecorder() { setAcceptDrops(true); }
protected:
- void mousePressEvent(QMouseEvent *)
+ void mousePressEvent(QMouseEvent *) override
{
QMimeData *mimeData = new QMimeData;
mimeData->setData("application/x-dnditemdata", "some data");
@@ -709,23 +709,23 @@ protected:
drag->exec();
}
- void dragEnterEvent(QDragEnterEvent *e)
+ void dragEnterEvent(QDragEnterEvent *e) override
{
e->accept();
_dndEvents.append(QStringLiteral("DragEnter "));
}
- void dragMoveEvent(QDragMoveEvent *e)
+ void dragMoveEvent(QDragMoveEvent *e) override
{
e->accept();
_dndEvents.append(QStringLiteral("DragMove "));
emit dragMoveReceived();
}
- void dragLeaveEvent(QDragLeaveEvent *e)
+ void dragLeaveEvent(QDragLeaveEvent *e) override
{
e->accept();
_dndEvents.append(QStringLiteral("DragLeave "));
}
- void dropEvent(QDropEvent *e)
+ void dropEvent(QDropEvent *e) override
{
e->accept();
_dndEvents.append(QStringLiteral("DropEvent "));
@@ -1055,7 +1055,7 @@ void tst_QWidget_window::tst_showhide_count()
return count;
}
protected:
- bool eventFilter(QObject *receiver, QEvent *event)
+ bool eventFilter(QObject *receiver, QEvent *event) override
{
if (QWidget *widget = qobject_cast<QWidget*>(receiver)) {
const auto entry = Entry(widget, event->type());
@@ -1341,7 +1341,7 @@ void tst_QWidget_window::mouseMoveWithPopup()
: QWidget(parent, flags|Qt::CustomizeWindowHint|Qt::FramelessWindowHint)
{}
- QSize sizeHint() const
+ QSize sizeHint() const override
{
if (parent())
return QSize(150, 100);
@@ -1360,7 +1360,7 @@ void tst_QWidget_window::mouseMoveWithPopup()
mouseReleaseCount = 0;
}
protected:
- void mousePressEvent(QMouseEvent *event)
+ void mousePressEvent(QMouseEvent *event) override
{
++mousePressCount;
@@ -1378,12 +1378,12 @@ void tst_QWidget_window::mouseMoveWithPopup()
QWidget::mousePressEvent(event);
}
}
- void mouseReleaseEvent(QMouseEvent *event)
+ void mouseReleaseEvent(QMouseEvent *event) override
{
++mouseReleaseCount;
QWidget::mouseReleaseEvent(event);
}
- void mouseMoveEvent(QMouseEvent *event)
+ void mouseMoveEvent(QMouseEvent *event) override
{
++mouseMoveCount;
QWidget::mouseMoveEvent(event);
diff --git a/tests/auto/widgets/kernel/qwidgetaction/tst_qwidgetaction.cpp b/tests/auto/widgets/kernel/qwidgetaction/tst_qwidgetaction.cpp
index 28731223a9..ad91cf3031 100644
--- a/tests/auto/widgets/kernel/qwidgetaction/tst_qwidgetaction.cpp
+++ b/tests/auto/widgets/kernel/qwidgetaction/tst_qwidgetaction.cpp
@@ -212,7 +212,7 @@ public:
QList<QWidget *> createdWidgets() const { return QWidgetAction::createdWidgets(); }
protected:
- virtual QWidget *createWidget(QWidget *parent);
+ virtual QWidget *createWidget(QWidget *parent) override;
};
QWidget *ComboAction::createWidget(QWidget *parent)
@@ -396,7 +396,7 @@ class CrashedAction : public QWidgetAction
public:
inline CrashedAction(QObject *parent) : QWidgetAction(parent) { }
- virtual QWidget *createWidget(QWidget *parent) {
+ virtual QWidget *createWidget(QWidget *parent) override {
return new QWidget(parent);
}
};
diff --git a/tests/auto/widgets/kernel/qwidgetmetatype/tst_qwidgetmetatype.cpp b/tests/auto/widgets/kernel/qwidgetmetatype/tst_qwidgetmetatype.cpp
index 0c99042e10..300320ca5d 100644
--- a/tests/auto/widgets/kernel/qwidgetmetatype/tst_qwidgetmetatype.cpp
+++ b/tests/auto/widgets/kernel/qwidgetmetatype/tst_qwidgetmetatype.cpp
@@ -64,10 +64,10 @@ static_assert((!QMetaTypeId2<QMap<QString,QSizePolicy> >::IsBuiltIn));
void tst_QWidgetMetaType::metaObject()
{
- QCOMPARE(QMetaType::metaObjectForType(qMetaTypeId<QWidget*>()), &QWidget::staticMetaObject);
- QCOMPARE(QMetaType::metaObjectForType(qMetaTypeId<QLabel*>()), &QLabel::staticMetaObject);
- QCOMPARE(QMetaType::metaObjectForType(qMetaTypeId<CustomWidget*>()), &CustomWidget::staticMetaObject);
- QCOMPARE(QMetaType::metaObjectForType(qMetaTypeId<QSizePolicy>()), &QSizePolicy::staticMetaObject);
+ QCOMPARE(QMetaType::fromType<QWidget*>().metaObject(), &QWidget::staticMetaObject);
+ QCOMPARE(QMetaType::fromType<QLabel*>().metaObject(), &QLabel::staticMetaObject);
+ QCOMPARE(QMetaType::fromType<CustomWidget*>().metaObject(), &CustomWidget::staticMetaObject);
+ QCOMPARE(QMetaType::fromType<QSizePolicy>().metaObject(), &QSizePolicy::staticMetaObject);
}
template <typename T>
@@ -93,25 +93,25 @@ void tst_QWidgetMetaType::saveAndLoadBuiltin()
QFETCH(int, type);
QFETCH(bool, isStreamable);
- void *value = QMetaType::create(type);
+ void *value = QMetaType(type).create();
QByteArray ba;
QDataStream stream(&ba, QIODevice::ReadWrite);
- QCOMPARE(QMetaType::save(stream, type, value), isStreamable);
+ QCOMPARE(QMetaType(type).save(stream, value), isStreamable);
QCOMPARE(stream.status(), QDataStream::Ok);
if (isStreamable)
- QVERIFY(QMetaType::load(stream, type, value));
+ QVERIFY(QMetaType(type).load(stream, value));
stream.device()->seek(0);
stream.resetStatus();
- QCOMPARE(QMetaType::load(stream, type, value), isStreamable);
+ QCOMPARE(QMetaType(type).load(stream, value), isStreamable);
QCOMPARE(stream.status(), QDataStream::Ok);
if (isStreamable)
- QVERIFY(QMetaType::load(stream, type, value));
+ QVERIFY(QMetaType(type).load(stream, value));
- QMetaType::destroy(type, value);
+ QMetaType(type).destroy(value);
}
diff --git a/tests/auto/widgets/kernel/qwidgetsvariant/tst_qwidgetsvariant.cpp b/tests/auto/widgets/kernel/qwidgetsvariant/tst_qwidgetsvariant.cpp
index fd26e3e4c5..95bad0e903 100644
--- a/tests/auto/widgets/kernel/qwidgetsvariant/tst_qwidgetsvariant.cpp
+++ b/tests/auto/widgets/kernel/qwidgetsvariant/tst_qwidgetsvariant.cpp
@@ -83,7 +83,7 @@ void tst_QWidgetsVariant::constructor_invalid()
}
{
QTest::ignoreMessage(QtWarningMsg, QRegularExpression("^Trying to construct an instance of an invalid type, type id:"));
- QVariant variant(typeId, /* copy */ 0);
+ QVariant variant(QMetaType(typeId), nullptr);
QVERIFY(!variant.isValid());
QCOMPARE(variant.userType(), int(QMetaType::UnknownType));
}
@@ -176,24 +176,24 @@ void tst_QWidgetsVariant::qvariant_cast_QObject()
if (success) {
QCOMPARE(o->objectName(), QString::fromLatin1("Hello"));
QVERIFY(data.canConvert<QObject*>());
- QVERIFY(data.canConvert(QMetaType::QObjectStar));
- QVERIFY(data.canConvert(::qMetaTypeId<QObject*>()));
+ QVERIFY(data.canConvert(QMetaType(QMetaType::QObjectStar)));
+ QVERIFY(data.canConvert(QMetaType::fromType<QObject*>()));
QVERIFY(data.value<QObject*>());
- QVERIFY(data.convert(QMetaType::QObjectStar));
- QCOMPARE(data.userType(), int(QMetaType::QObjectStar));
+ QVERIFY(data.convert(QMetaType(QMetaType::QObjectStar)));
+ QCOMPARE(data.metaType().id(), int(QMetaType::QObjectStar));
QVERIFY(data.canConvert<QWidget*>());
- QVERIFY(data.canConvert(::qMetaTypeId<QWidget*>()));
+ QVERIFY(data.canConvert(QMetaType::fromType<QWidget*>()));
QVERIFY(data.value<QWidget*>());
- QVERIFY(data.convert(qMetaTypeId<QWidget*>()));
- QCOMPARE(data.userType(), qMetaTypeId<QWidget*>());
+ QVERIFY(data.convert(QMetaType::fromType<QWidget*>()));
+ QCOMPARE(data.metaType(), QMetaType::fromType<QWidget*>());
} else {
QVERIFY(!data.canConvert<QObject*>());
- QVERIFY(!data.canConvert(QMetaType::QObjectStar));
- QVERIFY(!data.canConvert(::qMetaTypeId<QObject*>()));
+ QVERIFY(!data.canConvert(QMetaType(QMetaType::QObjectStar)));
+ QVERIFY(!data.canConvert(QMetaType::fromType<QObject*>()));
QVERIFY(!data.value<QObject*>());
- QVERIFY(!data.convert(QMetaType::QObjectStar));
- QVERIFY(data.userType() != QMetaType::QObjectStar);
+ QVERIFY(!data.convert(QMetaType(QMetaType::QObjectStar)));
+ QVERIFY(data.metaType().id() != QMetaType::QObjectStar);
}
delete o;
}
@@ -215,7 +215,7 @@ void tst_QWidgetsVariant::debugStream_data()
QTest::addColumn<QVariant>("variant");
QTest::addColumn<int>("typeId");
for (int id = QMetaType::LastGuiType + 1; id < QMetaType::User; ++id) {
- const char *tagName = QMetaType::typeName(id);
+ const char *tagName = QMetaType(id).name();
if (!tagName)
continue;
QTest::newRow(tagName) << QVariant(static_cast<QVariant::Type>(id)) << id;
diff --git a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp
index 2a8edaf1a2..ec646ccbe3 100644
--- a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp
+++ b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp
@@ -49,7 +49,8 @@ public:
{
}
- void exposeEvent(QExposeEvent *) {
+ void exposeEvent(QExposeEvent *) override
+ {
if (isExposed())
++numberOfExposes;
else
diff --git a/tests/auto/widgets/styles/qmacstyle/tst_qmacstyle.cpp b/tests/auto/widgets/styles/qmacstyle/tst_qmacstyle.cpp
index 899d090b5e..4a5702b709 100644
--- a/tests/auto/widgets/styles/qmacstyle/tst_qmacstyle.cpp
+++ b/tests/auto/widgets/styles/qmacstyle/tst_qmacstyle.cpp
@@ -189,7 +189,6 @@ void tst_QMacStyle::sizeHints()
QDateTimeEdit dateTime1(&w);
QCOMPARE(sh(&dateTime1).height(), h1);
- ok1.setAttribute(Qt::WA_MacMetalStyle, true);
QSize s2 = sh(&ok1);
if (size == Normal) {
QVERIFY(s2.height() >= 21 && s2.height() <= 32);
diff --git a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp
index 6963254484..b7b9ab6423 100644
--- a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp
+++ b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp
@@ -270,7 +270,7 @@ bool tst_QStyle::testAllFunctions(QStyle *style)
bool tst_QStyle::testScrollBarSubControls(const QStyle *style)
{
- const bool isMacStyle = style->objectName().compare(QLatin1String("macintosh"),
+ const bool isMacStyle = style->objectName().compare(QLatin1String("macos"),
Qt::CaseInsensitive) == 0;
QScrollBar scrollBar;
setFrameless(&scrollBar);
@@ -328,7 +328,7 @@ void tst_QStyle::testWindowsVistaStyle()
#ifdef Q_OS_MAC
void tst_QStyle::testMacStyle()
{
- QStyle *mstyle = QStyleFactory::create("Macintosh");
+ QStyle *mstyle = QStyleFactory::create("macos");
QVERIFY(testAllFunctions(mstyle));
delete mstyle;
}
diff --git a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
index 00939e5118..a751fae05d 100644
--- a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
+++ b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
@@ -72,8 +72,6 @@ class tst_QStyleSheetStyle : public QObject
public:
tst_QStyleSheetStyle();
- static void initMain();
-
private slots:
void init();
void cleanup();
@@ -173,12 +171,6 @@ private:
QSize m_testSize;
};
-// highdpiImages() tests HighDPI scaling; disable initially.
-void tst_QStyleSheetStyle::initMain()
-{
- QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling);
-}
-
tst_QStyleSheetStyle::tst_QStyleSheetStyle()
{
const int testSize = qMax(200, m_availableGeometry.width() / 10);
@@ -2111,13 +2103,13 @@ void tst_QStyleSheetStyle::widgetStylePropagation()
QLabel childLabel(&parentLabel);
childLabel.setObjectName("childLabel");
- if (parentFont.resolve())
+ if (parentFont.resolveMask())
parentLabel.setFont(parentFont);
- if (childFont.resolve())
+ if (childFont.resolveMask())
childLabel.setFont(childFont);
- if (parentPalette.resolve())
+ if (parentPalette.resolveMask())
parentLabel.setPalette(parentPalette);
- if (childPalette.resolve())
+ if (childPalette.resolveMask())
childLabel.setPalette(childPalette);
if (!parentStyleSheet.isEmpty())
parentLabel.setStyleSheet(parentStyleSheet);
@@ -2215,8 +2207,9 @@ void tst_QStyleSheetStyle::highdpiImages()
w.setWindowTitle(QLatin1String(QTest::currentTestFunction()) + QLatin1String("::")
+ QLatin1String(QTest::currentDataTag()));
QScreen *screen = QGuiApplication::primaryScreen();
+ auto inverseDpr = 1 / screen->devicePixelRatio();
w.move(screen->availableGeometry().topLeft());
- QHighDpiScaling::setScreenFactor(screen, screenFactor);
+ QHighDpiScaling::setScreenFactor(screen, inverseDpr * screenFactor);
w.setStyleSheet("QWidget { background-image: url(\":/images/testimage.png\"); }");
w.show();
diff --git a/tests/auto/widgets/util/qscroller/tst_qscroller.cpp b/tests/auto/widgets/util/qscroller/tst_qscroller.cpp
index 71b8867d09..7272e53dc9 100644
--- a/tests/auto/widgets/util/qscroller/tst_qscroller.cpp
+++ b/tests/auto/widgets/util/qscroller/tst_qscroller.cpp
@@ -52,7 +52,7 @@ public:
receivedOvershoot = false;
}
- bool event(QEvent *e)
+ bool event(QEvent *e) override
{
switch (e->type()) {
case QEvent::Gesture:
diff --git a/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp b/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
index e5a891912f..3b2bc1d126 100644
--- a/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+++ b/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
@@ -103,7 +103,7 @@ class MyButton : public QAbstractButton
{
public:
MyButton(QWidget *p = 0) : QAbstractButton(p) {}
- void paintEvent(QPaintEvent *)
+ void paintEvent(QPaintEvent *) override
{
QPainter p(this);
QRect r = rect();
@@ -124,7 +124,7 @@ public:
#endif
}
}
- QSize sizeHint() const
+ QSize sizeHint() const override
{
QSize sh(8, 8);
if (!text().isEmpty())
@@ -139,7 +139,7 @@ private:
int timerEvents;
- void timerEvent(QTimerEvent *event)
+ void timerEvent(QTimerEvent *event) override
{
++timerEvents;
QAbstractButton::timerEvent(event);
diff --git a/tests/auto/widgets/widgets/qabstractscrollarea/tst_qabstractscrollarea.cpp b/tests/auto/widgets/widgets/qabstractscrollarea/tst_qabstractscrollarea.cpp
index fd1e5c267d..86a5ebc114 100644
--- a/tests/auto/widgets/widgets/qabstractscrollarea/tst_qabstractscrollarea.cpp
+++ b/tests/auto/widgets/widgets/qabstractscrollarea/tst_qabstractscrollarea.cpp
@@ -291,7 +291,7 @@ public:
startTimer(2000);
}
- void timerEvent(QTimerEvent * /* event */)
+ void timerEvent(QTimerEvent * /* event */) override
{
// should not crash.
(void)new QScrollArea(this);
diff --git a/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp b/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp
index dd8a3e5839..e3448fa93d 100644
--- a/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp
+++ b/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp
@@ -51,7 +51,7 @@ public:
{ }
protected:
- void focusInEvent(QFocusEvent *)
+ void focusInEvent(QFocusEvent *) override
{
QCoreApplication::postEvent(this, new QKeyEvent(QEvent::KeyPress,
Qt::Key_Down, Qt::NoModifier));
diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
index da010ac357..2ceba99d91 100644
--- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
@@ -175,26 +175,26 @@ class MyAbstractItemDelegate : public QAbstractItemDelegate
{
public:
MyAbstractItemDelegate() : QAbstractItemDelegate() {};
- void paint(QPainter *, const QStyleOptionViewItem &, const QModelIndex &) const {}
- QSize sizeHint(const QStyleOptionViewItem &, const QModelIndex &) const { return QSize(); }
+ void paint(QPainter *, const QStyleOptionViewItem &, const QModelIndex &) const override {}
+ QSize sizeHint(const QStyleOptionViewItem &, const QModelIndex &) const override { return QSize(); }
};
class MyAbstractItemModel: public QAbstractItemModel
{
public:
MyAbstractItemModel() : QAbstractItemModel() {};
- QModelIndex index(int, int, const QModelIndex &) const { return QModelIndex(); }
- QModelIndex parent(const QModelIndex &) const { return QModelIndex(); }
- int rowCount(const QModelIndex &) const { return 0; }
- int columnCount(const QModelIndex &) const { return 0; }
- bool hasChildren(const QModelIndex &) const { return false; }
- QVariant data(const QModelIndex &, int) const { return QVariant(); }
- bool setData(const QModelIndex &, const QVariant &, int) { return false; }
- bool insertRows(int, int, const QModelIndex &) { return false; }
- bool insertColumns(int, int, const QModelIndex &) { return false; }
+ QModelIndex index(int, int, const QModelIndex &) const override { return QModelIndex(); }
+ QModelIndex parent(const QModelIndex &) const override { return QModelIndex(); }
+ int rowCount(const QModelIndex &) const override { return 0; }
+ int columnCount(const QModelIndex &) const override { return 0; }
+ bool hasChildren(const QModelIndex &) const override { return false; }
+ QVariant data(const QModelIndex &, int) const override { return QVariant(); }
+ bool setData(const QModelIndex &, const QVariant &, int) override { return false; }
+ bool insertRows(int, int, const QModelIndex &) override { return false; }
+ bool insertColumns(int, int, const QModelIndex &) override { return false; }
void setPersistent(const QModelIndex &, const QModelIndex &) {}
- bool removeRows (int, int, const QModelIndex &) { return false; }
- bool removeColumns(int, int, const QModelIndex &) { return false; }
+ bool removeRows (int, int, const QModelIndex &) override { return false; }
+ bool removeColumns(int, int, const QModelIndex &) override { return false; }
void reset() {}
};
@@ -202,16 +202,16 @@ class MyAbstractItemView : public QAbstractItemView
{
public:
MyAbstractItemView() : QAbstractItemView() {}
- QRect visualRect(const QModelIndex &) const { return QRect(); }
- void scrollTo(const QModelIndex &, ScrollHint) {}
- QModelIndex indexAt(const QPoint &) const { return QModelIndex(); }
+ QRect visualRect(const QModelIndex &) const override { return QRect(); }
+ void scrollTo(const QModelIndex &, ScrollHint) override {}
+ QModelIndex indexAt(const QPoint &) const override { return QModelIndex(); }
protected:
- QModelIndex moveCursor(CursorAction, Qt::KeyboardModifiers) { return QModelIndex(); }
- int horizontalOffset() const { return 0; }
- int verticalOffset() const { return 0; }
- bool isIndexHidden(const QModelIndex &) const { return false; }
- void setSelection(const QRect &, QItemSelectionModel::SelectionFlags) {}
- QRegion visualRegionForSelection(const QItemSelection &) const { return QRegion(); }
+ QModelIndex moveCursor(CursorAction, Qt::KeyboardModifiers) override { return QModelIndex(); }
+ int horizontalOffset() const override { return 0; }
+ int verticalOffset() const override { return 0; }
+ bool isIndexHidden(const QModelIndex &) const override { return false; }
+ void setSelection(const QRect &, QItemSelectionModel::SelectionFlags) override {}
+ QRegion visualRegionForSelection(const QItemSelection &) const override { return QRegion(); }
};
void tst_QComboBox::initTestCase()
@@ -1831,7 +1831,7 @@ public:
box->setGeometry(rect());
}
- void keyPressEvent(QKeyEvent *e)
+ void keyPressEvent(QKeyEvent *e) override
{
received = (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter);
}
@@ -2666,13 +2666,13 @@ void tst_QComboBox::task260974_menuItemRectangleForComboBoxPopup()
public:
TestStyle() : QProxyStyle(QStyleFactory::create("windows")) { }
- int styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget, QStyleHintReturn *ret) const
+ int styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget, QStyleHintReturn *ret) const override
{
if (hint == SH_ComboBox_Popup) return 1;
else return QCommonStyle::styleHint(hint, option, widget, ret);
}
- void drawControl(ControlElement element, const QStyleOption *option, QPainter *, const QWidget *) const
+ void drawControl(ControlElement element, const QStyleOption *option, QPainter *, const QWidget *) const override
{
if (element == CE_MenuItem)
discoveredRect = option->rect;
diff --git a/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp b/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp
index 55be152e40..84a4f9e5a0 100644
--- a/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp
+++ b/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp
@@ -864,18 +864,18 @@ void tst_QDockWidget::task169808_setFloating()
class MyWidget : public QWidget
{
public:
- QSize sizeHint() const
+ QSize sizeHint() const override
{
const QRect& deskRect = QGuiApplication::primaryScreen()->availableGeometry();
return QSize(qMin(300, deskRect.width() / 2), qMin(300, deskRect.height() / 2));
}
- QSize minimumSizeHint() const
+ QSize minimumSizeHint() const override
{
return QSize(20,20);
}
- void paintEvent(QPaintEvent *)
+ void paintEvent(QPaintEvent *) override
{
QPainter p(this);
p.fillRect(rect(), Qt::red);
diff --git a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp
index cec2da1d57..67813bdeac 100644
--- a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp
+++ b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp
@@ -52,25 +52,25 @@ public:
DoubleSpinBox(QWidget *parent = 0)
: QDoubleSpinBox(parent)
{ /*connect(this, SIGNAL(valueChanged(double)), this, SLOT(foo(double)));*/ }
- QString textFromValue(double v) const
+ QString textFromValue(double v) const override
{
return QDoubleSpinBox::textFromValue(v);
}
- QValidator::State validate(QString &text, int &pos) const
+ QValidator::State validate(QString &text, int &pos) const override
{
return QDoubleSpinBox::validate(text, pos);
}
- double valueFromText(const QString &text) const
+ double valueFromText(const QString &text) const override
{
return QDoubleSpinBox::valueFromText(text);
}
#if QT_CONFIG(wheelevent)
- void wheelEvent(QWheelEvent *event)
+ void wheelEvent(QWheelEvent *event) override
{
QDoubleSpinBox::wheelEvent(event);
}
#endif
- void initStyleOption(QStyleOptionSpinBox *option) const
+ void initStyleOption(QStyleOptionSpinBox *option) const override
{
QDoubleSpinBox::initStyleOption(option);
}
@@ -1172,7 +1172,7 @@ void tst_QDoubleSpinBox::taskQTBUG_5008_textFromValueAndValidate()
}
//we use the French delimiters here
- QString textFromValue (double value) const
+ QString textFromValue (double value) const override
{
return locale().toString(value);
}
diff --git a/tests/auto/widgets/widgets/qfocusframe/tst_qfocusframe.cpp b/tests/auto/widgets/widgets/qfocusframe/tst_qfocusframe.cpp
index 657a1ea55c..563f3c6e7b 100644
--- a/tests/auto/widgets/widgets/qfocusframe/tst_qfocusframe.cpp
+++ b/tests/auto/widgets/widgets/qfocusframe/tst_qfocusframe.cpp
@@ -79,7 +79,7 @@ void tst_QFocusFrame::focusFrameInsideScrollview()
// is why special considerations are taken inside the focus frame to
// prevent the frame to scroll away from the widget it tracks.
- if (qApp->style()->objectName() != QLatin1String("macintosh"))
+ if (qApp->style()->objectName() != QLatin1String("macos"))
QSKIP("This test is only valid when using a style that has a focus frame");
QWidget window;
diff --git a/tests/auto/widgets/widgets/qframe/.prev_CMakeLists.txt b/tests/auto/widgets/widgets/qframe/.prev_CMakeLists.txt
new file mode 100644
index 0000000000..89f91d1967
--- /dev/null
+++ b/tests/auto/widgets/widgets/qframe/.prev_CMakeLists.txt
@@ -0,0 +1,20 @@
+# Generated from qframe.pro.
+
+#####################################################################
+## tst_qframe Test:
+#####################################################################
+
+# Collect test data
+file(GLOB_RECURSE test_data_glob
+ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
+ images/*)
+list(APPEND test_data ${test_data_glob})
+
+qt_add_test(tst_qframe
+ SOURCES
+ tst_qframe.cpp
+ PUBLIC_LIBRARIES
+ Qt::Gui
+ Qt::Widgets
+ TESTDATA ${test_data}
+)
diff --git a/tests/auto/widgets/widgets/qframe/CMakeLists.txt b/tests/auto/widgets/widgets/qframe/CMakeLists.txt
index 89f91d1967..be08a9b797 100644
--- a/tests/auto/widgets/widgets/qframe/CMakeLists.txt
+++ b/tests/auto/widgets/widgets/qframe/CMakeLists.txt
@@ -11,6 +11,7 @@ file(GLOB_RECURSE test_data_glob
list(APPEND test_data ${test_data_glob})
qt_add_test(tst_qframe
+ LOWDPI # special case
SOURCES
tst_qframe.cpp
PUBLIC_LIBRARIES
diff --git a/tests/auto/widgets/widgets/qframe/qframe.pro b/tests/auto/widgets/widgets/qframe/qframe.pro
index 1da7eb1d11..cf874cbc8e 100644
--- a/tests/auto/widgets/widgets/qframe/qframe.pro
+++ b/tests/auto/widgets/widgets/qframe/qframe.pro
@@ -1,4 +1,4 @@
-CONFIG += testcase
+CONFIG += testcase testcase_lowdpi
TARGET = tst_qframe
QT += testlib widgets
diff --git a/tests/auto/widgets/widgets/qframe/tst_qframe.cpp b/tests/auto/widgets/widgets/qframe/tst_qframe.cpp
index 0ca8dc0776..b5272f6b1a 100644
--- a/tests/auto/widgets/widgets/qframe/tst_qframe.cpp
+++ b/tests/auto/widgets/widgets/qframe/tst_qframe.cpp
@@ -38,9 +38,6 @@ class tst_QFrame : public QObject
{
Q_OBJECT
-public:
- static void initMain() { QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling); }
-
private slots:
void testDefaults();
void testInitStyleOption_data();
diff --git a/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp b/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
index a164be8712..d9cd5ad136 100644
--- a/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+++ b/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
@@ -523,17 +523,17 @@ public:
}
protected:
- void mousePressEvent(QMouseEvent*)
+ void mousePressEvent(QMouseEvent*) override
{
mousePressed = true;
}
- void mouseReleaseEvent(QMouseEvent*)
+ void mouseReleaseEvent(QMouseEvent*) override
{
mouseReleased = true;
}
- void mouseMoveEvent(QMouseEvent*)
+ void mouseMoveEvent(QMouseEvent*) override
{
mouseMoved = true;
}
diff --git a/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp b/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp
index eb34a5ad4e..d4bc816ec0 100644
--- a/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp
+++ b/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp
@@ -391,7 +391,7 @@ void tst_QLabel::task226479_movieResize()
{
class Label : public QLabel {
protected:
- void paintEvent(QPaintEvent *e)
+ void paintEvent(QPaintEvent *e) override
{
paintedRegion += e->region();
QLabel::paintEvent(e);
diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
index 2367d56dad..87be592e2b 100644
--- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
+++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
@@ -906,7 +906,7 @@ public:
: QValidator(parent)
{}
- QValidator::State validate(QString &str, int &) const
+ QValidator::State validate(QString &str, int &) const override
{
const int s = str.size();
if (s < chars) {
@@ -917,7 +917,7 @@ public:
return Acceptable;
}
- void fixup(QString &str) const
+ void fixup(QString &str) const override
{
str = str.leftJustified(chars, 'X', true);
}
@@ -1930,7 +1930,7 @@ void tst_QLineEdit::isReadOnly()
class BlinkTestLineEdit : public QLineEdit
{
public:
- void paintEvent(QPaintEvent *e)
+ void paintEvent(QPaintEvent *e) override
{
++updates;
QLineEdit::paintEvent(e);
@@ -2431,7 +2431,7 @@ void tst_QLineEdit::returnPressed()
class QIntFixValidator : public QIntValidator {
public:
QIntFixValidator(int min, int max, QObject *parent) : QIntValidator(min, max, parent) {}
- void fixup (QString &input) const {
+ void fixup (QString &input) const override {
for (int i=0; i<input.length(); ++i)
if (!input.at(i).isNumber()) {
input[(int)i] = QChar('0');
@@ -3149,7 +3149,7 @@ class InputMaskValidator : public QValidator
{
public:
InputMaskValidator(QObject *parent, const char *name = 0) : QValidator(parent) { setObjectName(name); }
- State validate(QString &text, int &pos) const
+ State validate(QString &text, int &pos) const override
{
InputMaskValidator *that = (InputMaskValidator *)this;
that->validateText = text;
@@ -3219,7 +3219,7 @@ class LineEdit : public QLineEdit
public:
LineEdit() { state = Other; }
- void keyPressEvent(QKeyEvent *e)
+ void keyPressEvent(QKeyEvent *e) override
{
QLineEdit::keyPressEvent(e);
if (e->key() == Qt::Key_Enter) {
@@ -4048,7 +4048,7 @@ class UpdateRegionLineEdit : public QLineEdit
public:
QRegion updateRegion;
protected:
- void paintEvent(QPaintEvent *event)
+ void paintEvent(QPaintEvent *event) override
{
updateRegion = event->region();
}
diff --git a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp
index 15890bfd9c..b0fc8a3bfa 100644
--- a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp
+++ b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp
@@ -65,7 +65,7 @@ public:
{
m_timerId = startTimer(200);
}
- void timerEvent(QTimerEvent*)
+ void timerEvent(QTimerEvent*) override
{
QCoreApplication::postEvent(m_tb, new QMouseEvent(QEvent::MouseButtonPress, QPoint(6, 7), Qt::LeftButton, {}, {}));
QCoreApplication::postEvent(m_tb, new QMouseEvent(QEvent::MouseMove, QPoint(7, 8), Qt::LeftButton, Qt::LeftButton, {}));
@@ -89,7 +89,7 @@ public:
m_timerId = startTimer(100);
}
- void timerEvent(QTimerEvent*)
+ void timerEvent(QTimerEvent*) override
{
QCoreApplication::postEvent(m_w, new QMouseEvent(QEvent::MouseButtonPress, QPoint(230, 370), Qt::LeftButton, {}, {}));
QCoreApplication::postEvent(m_w, new QMouseEvent(QEvent::MouseButtonRelease, QPoint(230, 370), Qt::LeftButton, {}, {}));
@@ -1468,7 +1468,7 @@ public:
{
}
- QSize sizeHint() const
+ QSize sizeHint() const override
{
return QSize(200, 200);
}
diff --git a/tests/auto/widgets/widgets/qmdiarea/BLACKLIST b/tests/auto/widgets/widgets/qmdiarea/BLACKLIST
index 6010772be7..dc60324ba5 100644
--- a/tests/auto/widgets/widgets/qmdiarea/BLACKLIST
+++ b/tests/auto/widgets/widgets/qmdiarea/BLACKLIST
@@ -4,6 +4,7 @@ rhel-7.6
opensuse-leap
macos
ubuntu-18.04
+ubuntu-20.04
macos
rhel-7.4
macos
diff --git a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp
index 8def1a11fc..53dbf2012f 100644
--- a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp
+++ b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp
@@ -792,7 +792,7 @@ class MyChild : public QWidget
{
public:
MyChild(QWidget *parent = 0) : QWidget(parent) {}
- QSize sizeHint() const { return QSize(234, 123); }
+ QSize sizeHint() const override { return QSize(234, 123); }
};
void tst_QMdiArea::childSize()
@@ -866,8 +866,8 @@ class LargeWidget : public QWidget
{
public:
LargeWidget(QWidget *parent = 0) : QWidget(parent) {}
- QSize sizeHint() const { return QSize(1280, 1024); }
- QSize minimumSizeHint() const { return QSize(300, 300); }
+ QSize sizeHint() const override { return QSize(1280, 1024); }
+ QSize minimumSizeHint() const override { return QSize(300, 300); }
};
// New tests
@@ -2051,7 +2051,7 @@ public:
void clear() { _count = 0; }
protected:
- bool eventFilter(QObject *object, QEvent *event)
+ bool eventFilter(QObject *object, QEvent *event) override
{
if (event->type() == eventToSpy)
++_count;
diff --git a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp
index fd7775d944..8121a3637f 100644
--- a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp
+++ b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp
@@ -260,7 +260,7 @@ void tst_QMdiSubWindow::minimumSizeHint()
public:
Widget() = default;
- QSize minimumSizeHint() const
+ QSize minimumSizeHint() const override
{
return QSize(100, 100);
}
diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
index 783476cf67..81ec5c77d0 100644
--- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
+++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
@@ -979,7 +979,7 @@ class Menu258920 : public QMenu
{
Q_OBJECT
public slots:
- void paintEvent(QPaintEvent *e)
+ void paintEvent(QPaintEvent *e) override
{
QMenu::paintEvent(e);
painted = true;
@@ -1410,7 +1410,7 @@ void tst_QMenu::widgetActionTriggerClosesMenu()
}
protected:
- QWidget *createWidget(QWidget *parent)
+ QWidget *createWidget(QWidget *parent) override
{
QPushButton *button = new QPushButton(QLatin1String("Button"), parent);
connect(button, &QPushButton::clicked, this, &QAction::trigger);
diff --git a/tests/auto/widgets/widgets/qmenubar/BLACKLIST b/tests/auto/widgets/widgets/qmenubar/BLACKLIST
index 41b440d3d6..d412fe6e81 100644
--- a/tests/auto/widgets/widgets/qmenubar/BLACKLIST
+++ b/tests/auto/widgets/widgets/qmenubar/BLACKLIST
@@ -2,5 +2,6 @@
ubuntu-16.04
#QTBUG-66255
ubuntu-18.04
+ubuntu-20.04
[activatedCount]
opensuse-42.3
diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
index 39ab5f6ebf..7a9676f56b 100644
--- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
+++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
@@ -290,7 +290,7 @@ QAction *tst_QMenuBar::createCharacterAction(QMenu *menu, char lowerAscii)
action->setObjectName(text);
action->setData(QVariant(int(lowerAscii)));
#if QT_CONFIG(shortcut)
- action->setShortcut(Qt::CTRL + (lowerAscii - 'a' + Qt::Key_A));
+ action->setShortcut(Qt::CTRL + Qt::Key(lowerAscii - 'a' + int(Qt::Key_A)));
#endif
connect(action, SIGNAL(triggered()), this, SLOT(onComplexActionTriggered()));
return action;
diff --git a/tests/auto/widgets/widgets/qopenglwidget/.prev_CMakeLists.txt b/tests/auto/widgets/widgets/qopenglwidget/.prev_CMakeLists.txt
new file mode 100644
index 0000000000..d1af2e811c
--- /dev/null
+++ b/tests/auto/widgets/widgets/qopenglwidget/.prev_CMakeLists.txt
@@ -0,0 +1,18 @@
+# Generated from qopenglwidget.pro.
+
+#####################################################################
+## tst_qopenglwidget Test:
+#####################################################################
+
+qt_add_test(tst_qopenglwidget
+ SOURCES
+ tst_qopenglwidget.cpp
+ PUBLIC_LIBRARIES
+ Qt::CorePrivate
+ Qt::Gui
+ Qt::GuiPrivate
+ Qt::OpenGL
+ Qt::OpenGLPrivate
+ Qt::OpenGLWidgets
+ Qt::Widgets
+)
diff --git a/tests/auto/widgets/widgets/qopenglwidget/CMakeLists.txt b/tests/auto/widgets/widgets/qopenglwidget/CMakeLists.txt
index d1af2e811c..036f3316d9 100644
--- a/tests/auto/widgets/widgets/qopenglwidget/CMakeLists.txt
+++ b/tests/auto/widgets/widgets/qopenglwidget/CMakeLists.txt
@@ -5,6 +5,7 @@
#####################################################################
qt_add_test(tst_qopenglwidget
+ LOWDPI # special case
SOURCES
tst_qopenglwidget.cpp
PUBLIC_LIBRARIES
diff --git a/tests/auto/widgets/widgets/qopenglwidget/qopenglwidget.pro b/tests/auto/widgets/widgets/qopenglwidget/qopenglwidget.pro
index 792bbf4529..9a6b0e2040 100644
--- a/tests/auto/widgets/widgets/qopenglwidget/qopenglwidget.pro
+++ b/tests/auto/widgets/widgets/qopenglwidget/qopenglwidget.pro
@@ -1,4 +1,4 @@
-CONFIG += testcase
+CONFIG += testcase testcase_lowdpi
TARGET = tst_qopenglwidget
QT += opengl opengl-private gui-private core-private testlib widgets openglwidgets
diff --git a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp
index 099a099c13..a18fd0299a 100644
--- a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp
+++ b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp
@@ -48,9 +48,6 @@ class tst_QOpenGLWidget : public QObject
{
Q_OBJECT
-public:
- static void initMain() { QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling); }
-
private slots:
void initTestCase();
void create();
@@ -708,7 +705,7 @@ public:
{
}
- void paintEvent(QPaintEvent *)
+ void paintEvent(QPaintEvent *) override
{
QPainter p(this);
text.setText(QStringLiteral("test"));
diff --git a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp
index 2f69518663..e3812f16d0 100644
--- a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp
+++ b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp
@@ -150,7 +150,9 @@ private slots:
#if QT_CONFIG(scrollbar)
void updateAfterChangeCenterOnScroll();
#endif
+#ifndef QT_NO_CLIPBOARD
void updateCursorPositionAfterEdit();
+#endif
private:
void createSelection();
@@ -220,18 +222,18 @@ public:
inline QtTestDocumentLayout(QPlainTextEdit *edit, QTextDocument *doc, int &itCount)
: QAbstractTextDocumentLayout(doc), useBiggerSize(false), ed(edit), iterationCounter(itCount) {}
- virtual void draw(QPainter *, const QAbstractTextDocumentLayout::PaintContext &) {}
+ virtual void draw(QPainter *, const QAbstractTextDocumentLayout::PaintContext &) override {}
- virtual int hitTest(const QPointF &, Qt::HitTestAccuracy ) const { return 0; }
+ virtual int hitTest(const QPointF &, Qt::HitTestAccuracy ) const override { return 0; }
- virtual void documentChanged(int, int, int) {}
+ virtual void documentChanged(int, int, int) override {}
- virtual int pageCount() const { return 1; }
+ virtual int pageCount() const override { return 1; }
- virtual QSizeF documentSize() const { return usedSize; }
+ virtual QSizeF documentSize() const override { return usedSize; }
- virtual QRectF frameBoundingRect(QTextFrame *) const { return QRectF(); }
- virtual QRectF blockBoundingRect(const QTextBlock &) const { return QRectF(); }
+ virtual QRectF frameBoundingRect(QTextFrame *) const override { return QRectF(); }
+ virtual QRectF blockBoundingRect(const QTextBlock &) const override { return QRectF(); }
bool useBiggerSize;
QSize usedSize;
@@ -1102,15 +1104,15 @@ public:
mutable int canInsertCallCount;
mutable int insertCallCount;
- virtual QMimeData *createMimeDataFromSelection() const {
+ virtual QMimeData *createMimeDataFromSelection() const override {
createMimeDataCallCount++;
return QPlainTextEdit::createMimeDataFromSelection();
}
- virtual bool canInsertFromMimeData(const QMimeData *source) const {
+ virtual bool canInsertFromMimeData(const QMimeData *source) const override {
canInsertCallCount++;
return QPlainTextEdit::canInsertFromMimeData(source);
}
- virtual void insertFromMimeData(const QMimeData *source) {
+ virtual void insertFromMimeData(const QMimeData *source) override {
insertCallCount++;
QPlainTextEdit::insertFromMimeData(source);
}
@@ -1250,7 +1252,7 @@ public:
bool resizeEventCalled;
protected:
- virtual void resizeEvent(QResizeEvent *e)
+ virtual void resizeEvent(QResizeEvent *e) override
{
QPlainTextEdit::resizeEvent(e);
setPlainText("<img src=qtextbrowser-resizeevent.png width=" + QString::number(size().width()) + "><br>Size is " + QString::number(size().width()) + " x " + QString::number(size().height()));
@@ -1756,6 +1758,7 @@ void tst_QPlainTextEdit::updateAfterChangeCenterOnScroll()
#endif
+#ifndef QT_NO_CLIPBOARD
void tst_QPlainTextEdit::updateCursorPositionAfterEdit()
{
QPlainTextEdit plaintextEdit;
@@ -1800,6 +1803,7 @@ void tst_QPlainTextEdit::updateCursorPositionAfterEdit()
// The curser should move back to the end of the copied text
QCOMPARE(plaintextEdit.textCursor().position(), initialPosition + txt.length());
}
+#endif
QTEST_MAIN(tst_QPlainTextEdit)
#include "tst_qplaintextedit.moc"
diff --git a/tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp b/tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp
index a1097fa433..eb80460311 100644
--- a/tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp
+++ b/tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp
@@ -145,7 +145,7 @@ void tst_QProgressBar::text()
class ProgressBar : public QProgressBar
{
- void paintEvent(QPaintEvent *event)
+ void paintEvent(QPaintEvent *event) override
{
repainted = true;
QProgressBar::paintEvent(event);
diff --git a/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp b/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
index 634497f22f..d3314494d5 100644
--- a/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+++ b/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
@@ -516,7 +516,7 @@ void tst_QPushButton::sizeHint_data()
QTest::newRow("windows") << QString::fromLatin1("windows");
#endif
#if defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC)
- QTest::newRow("macintosh") << QString::fromLatin1("macintosh");
+ QTest::newRow("macos") << QString::fromLatin1("macos");
#endif
#if !defined(QT_NO_STYLE_FUSION)
QTest::newRow("fusion") << QString::fromLatin1("fusion");
@@ -686,7 +686,12 @@ void tst_QPushButton::hitButton()
QVBoxLayout *layout = new QVBoxLayout;
PushButton *button1 = new PushButton("Ok");
PushButton *button2 = new PushButton("Cancel");
- button2->setStyleSheet("QPushButton { margin: 10px; border-radius: 4px; border: 1px solid black; }");
+ button2->setStyleSheet("QPushButton {"
+ "padding: 5px;"
+ "margin: 5px;"
+ "border-radius: 4px;"
+ "border: 1px solid black; }"
+ );
layout->addWidget(button1);
layout->addWidget(button2);
@@ -700,7 +705,8 @@ void tst_QPushButton::hitButton()
const QPoint button2Center = button2->rect().center();
QVERIFY(button2->hitButton(button2Center));
- QVERIFY(!button2->hitButton(QPoint(0, 0)));
+ QVERIFY(button2->hitButton(QPoint(6, 6)));
+ QVERIFY(!button2->hitButton(QPoint(2, 2)));
}
QTEST_MAIN(tst_QPushButton)
diff --git a/tests/auto/widgets/widgets/qscrollarea/tst_qscrollarea.cpp b/tests/auto/widgets/widgets/qscrollarea/tst_qscrollarea.cpp
index 9f08bd337b..c14b3aa9d8 100644
--- a/tests/auto/widgets/widgets/qscrollarea/tst_qscrollarea.cpp
+++ b/tests/auto/widgets/widgets/qscrollarea/tst_qscrollarea.cpp
@@ -85,7 +85,7 @@ public:
setBackgroundRole(QPalette::Dark);
}
protected:
- QVariant inputMethodQuery(Qt::InputMethodQuery query) const
+ QVariant inputMethodQuery(Qt::InputMethodQuery query) const override
{
if (query == Qt::ImCursorRectangle)
return QRect(width() / 2, height() / 2, 5, 5);
@@ -120,7 +120,7 @@ class HFWWidget : public QWidget
{
public:
HFWWidget();
- int heightForWidth(int w) const;
+ int heightForWidth(int w) const override;
};
HFWWidget::HFWWidget()
diff --git a/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp b/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp
index 2452bc34c5..92771db764 100644
--- a/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp
+++ b/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp
@@ -101,8 +101,8 @@ void tst_QScrollBar::task_209492()
int scrollCount;
MyScrollArea(QWidget *parent = 0) : QScrollArea(parent), scrollCount(0) {}
protected:
- void paintEvent(QPaintEvent *) { QTest::qSleep(600); }
- void scrollContentsBy(int, int) { ++scrollCount; viewport()->update(); }
+ void paintEvent(QPaintEvent *) override { QTest::qSleep(600); }
+ void scrollContentsBy(int, int) override { ++scrollCount; viewport()->update(); }
};
MyScrollArea scrollArea;
diff --git a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp
index 9f109ab96c..e9c4d3b0d6 100644
--- a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp
+++ b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp
@@ -64,25 +64,25 @@ public:
SpinBox(QWidget *parent = 0)
: QSpinBox(parent)
{}
- QString textFromValue(int v) const
+ QString textFromValue(int v) const override
{
return QSpinBox::textFromValue(v);
}
- QValidator::State validate(QString &text, int &pos) const
+ QValidator::State validate(QString &text, int &pos) const override
{
return QSpinBox::validate(text, pos);
}
- int valueFromText(const QString &text) const
+ int valueFromText(const QString &text) const override
{
return QSpinBox::valueFromText(text);
}
#if QT_CONFIG(wheelevent)
- void wheelEvent(QWheelEvent *event)
+ void wheelEvent(QWheelEvent *event) override
{
QSpinBox::wheelEvent(event);
}
#endif
- void initStyleOption(QStyleOptionSpinBox *option) const
+ void initStyleOption(QStyleOptionSpinBox *option) const override
{
QSpinBox::initStyleOption(option);
}
@@ -510,7 +510,8 @@ class ReadOnlyChangeTracker: public QSpinBox
public:
ReadOnlyChangeTracker(QWidget *parent = 0) : QSpinBox(parent) {}
- void changeEvent(QEvent *ev) {
+ void changeEvent(QEvent *ev) override
+ {
if (ev->type() == QEvent::ReadOnlyChange)
++readOnlyChangeEventCount;
}
@@ -1138,7 +1139,7 @@ void tst_QSpinBox::textFromValue()
class sizeHint_SpinBox : public QSpinBox
{
public:
- QSize sizeHint() const
+ QSize sizeHint() const override
{
++sizeHintRequests;
return QSpinBox::sizeHint();
@@ -1198,7 +1199,7 @@ void tst_QSpinBox::taskQTBUG_5008_textFromValueAndValidate()
}
//we use the French delimiters here
- QString textFromValue (int value) const
+ QString textFromValue (int value) const override
{
return locale().toString(value);
}
diff --git a/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp b/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp
index aca795ff61..b63e917e5c 100644
--- a/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp
+++ b/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp
@@ -952,11 +952,11 @@ class MyTextEdit : public QTextEdit
{
setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
}
- virtual QSize minimumSizeHint () const
+ virtual QSize minimumSizeHint () const override
{
return QSize(200, 200) * m_iFactor;
}
- virtual QSize sizeHint() const
+ virtual QSize sizeHint() const override
{
return QSize(390, 390) * m_iFactor;
}
diff --git a/tests/auto/widgets/widgets/qstackedwidget/tst_qstackedwidget.cpp b/tests/auto/widgets/widgets/qstackedwidget/tst_qstackedwidget.cpp
index 4fd3661fa7..479c8a463d 100644
--- a/tests/auto/widgets/widgets/qstackedwidget/tst_qstackedwidget.cpp
+++ b/tests/auto/widgets/widgets/qstackedwidget/tst_qstackedwidget.cpp
@@ -128,13 +128,13 @@ public:
createWidgets();
}
- virtual void showEvent (QShowEvent *)
+ virtual void showEvent (QShowEvent *) override
{
if (!m_staticWidgets)
createWidgets();
}
- virtual void hideEvent (QHideEvent *)
+ virtual void hideEvent (QHideEvent *) override
{
if (!m_staticWidgets)
destroyWidgets();
diff --git a/tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp b/tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp
index 502535502d..2afbd44c03 100644
--- a/tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp
+++ b/tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp
@@ -702,7 +702,7 @@ public:
Widget10052(QWidget *parent) : QWidget(parent), moved(false)
{ }
- void moveEvent(QMoveEvent *e)
+ void moveEvent(QMoveEvent *e) override
{
moved = e->oldPos() != e->pos();
QWidget::moveEvent(e);
diff --git a/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp b/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp
index 25f61ec7ac..4bbd44283d 100644
--- a/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp
+++ b/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp
@@ -60,10 +60,12 @@ class QTabWidgetChild:public QTabWidget {
};
protected:
- virtual void tabInserted(int /*index */ ) {
+ virtual void tabInserted(int /*index */ ) override
+ {
tabCount++;
};
- virtual void tabRemoved(int /*index */ ) {
+ virtual void tabRemoved(int /*index */ ) override
+ {
tabCount--;
};
int tabCount;
@@ -553,7 +555,8 @@ public:
PaintCounter() :count(0) { setAttribute(Qt::WA_OpaquePaintEvent); }
int count;
protected:
- void paintEvent(QPaintEvent*) {
+ void paintEvent(QPaintEvent*) override
+ {
++count;
}
};
diff --git a/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp b/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp
index 7e99177dec..f562f84037 100644
--- a/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp
+++ b/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp
@@ -483,7 +483,8 @@ void tst_QTextBrowser::anchorsWithSelfBuiltHtml()
class HelpBrowser : public QTextBrowser
{
public:
- virtual QVariant loadResource(int /*type*/, const QUrl &name) {
+ virtual QVariant loadResource(int /*type*/, const QUrl &name) override
+ {
QString url = name.toString();
if(url == "qhelp://docs/index.html") {
return "index";
diff --git a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
index eaa7251684..4054e35e8d 100644
--- a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
+++ b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
@@ -334,18 +334,18 @@ public:
inline QtTestDocumentLayout(QTextEdit *edit, QTextDocument *doc, int &itCount)
: QAbstractTextDocumentLayout(doc), useBiggerSize(false), ed(edit), iterationCounter(itCount) {}
- virtual void draw(QPainter *, const QAbstractTextDocumentLayout::PaintContext &) {}
+ virtual void draw(QPainter *, const QAbstractTextDocumentLayout::PaintContext &) override {}
- virtual int hitTest(const QPointF &, Qt::HitTestAccuracy ) const { return 0; }
+ virtual int hitTest(const QPointF &, Qt::HitTestAccuracy ) const override { return 0; }
- virtual void documentChanged(int, int, int) {}
+ virtual void documentChanged(int, int, int) override {}
- virtual int pageCount() const { return 1; }
+ virtual int pageCount() const override { return 1; }
- virtual QSizeF documentSize() const { return usedSize; }
+ virtual QSizeF documentSize() const override { return usedSize; }
- virtual QRectF frameBoundingRect(QTextFrame *) const { return QRectF(); }
- virtual QRectF blockBoundingRect(const QTextBlock &) const { return QRectF(); }
+ virtual QRectF frameBoundingRect(QTextFrame *) const override { return QRectF(); }
+ virtual QRectF blockBoundingRect(const QTextBlock &) const override { return QRectF(); }
bool useBiggerSize;
QSize usedSize;
@@ -1444,15 +1444,15 @@ public:
mutable int canInsertCallCount;
mutable int insertCallCount;
- virtual QMimeData *createMimeDataFromSelection() const {
+ virtual QMimeData *createMimeDataFromSelection() const override {
createMimeDataCallCount++;
return QTextEdit::createMimeDataFromSelection();
}
- virtual bool canInsertFromMimeData(const QMimeData *source) const {
+ virtual bool canInsertFromMimeData(const QMimeData *source) const override {
canInsertCallCount++;
return QTextEdit::canInsertFromMimeData(source);
}
- virtual void insertFromMimeData(const QMimeData *source) {
+ virtual void insertFromMimeData(const QMimeData *source) override {
insertCallCount++;
QTextEdit::insertFromMimeData(source);
}
@@ -1604,7 +1604,7 @@ public:
bool resizeEventCalled;
protected:
- virtual void resizeEvent(QResizeEvent *e)
+ virtual void resizeEvent(QResizeEvent *e) override
{
QTextEdit::resizeEvent(e);
setHtml("<img src=qtextbrowser-resizeevent.png width=" + QString::number(size().width()) + "><br>Size is " + QString::number(size().width()) + " x " + QString::number(size().height()));
@@ -2005,7 +2005,8 @@ void tst_QTextEdit::fullWidthSelection()
// enable full-width-selection for our test widget.
class FullWidthStyle : public QCommonStyle {
- int styleHint(StyleHint stylehint, const QStyleOption *opt, const QWidget *widget, QStyleHintReturn *returnData) const {
+ int styleHint(StyleHint stylehint, const QStyleOption *opt, const QWidget *widget, QStyleHintReturn *returnData) const override
+ {
if (stylehint == QStyle::SH_RichText_FullWidthSelection)
return 1;
return QCommonStyle::styleHint(stylehint, opt, widget, returnData);
@@ -2565,7 +2566,7 @@ void tst_QTextEdit::highlightLongLine()
class NumHighlighter : public QSyntaxHighlighter {
public:
explicit NumHighlighter(QTextDocument*doc) : QSyntaxHighlighter(doc) {};
- virtual void highlightBlock(const QString& text) {
+ virtual void highlightBlock(const QString& text) override {
// odd number in bold
QTextCharFormat format;
format.setFontWeight(QFont::Bold);
@@ -2644,7 +2645,7 @@ public:
TextEdit(QWidget *parent = 0)
: QTextEdit(parent)
{}
- void wheelEvent(QWheelEvent *event)
+ void wheelEvent(QWheelEvent *event) override
{
QTextEdit::wheelEvent(event);
}
@@ -2703,12 +2704,12 @@ namespace {
}
- QPaintEngine *paintEngine () const
+ QPaintEngine *paintEngine () const override
{
return m_paintEngine;
}
- int metric (QPaintDevice::PaintDeviceMetric metric) const {
+ int metric (QPaintDevice::PaintDeviceMetric metric) const override {
switch (metric) {
case QPaintDevice::PdmWidth:
case QPaintDevice::PdmHeight:
diff --git a/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp b/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp
index 6111d5b0dd..32003f2124 100644
--- a/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp
+++ b/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp
@@ -61,6 +61,17 @@ private:
QPointer<QWidget> m_menu;
};
+class MyToolButton : public QToolButton
+{
+ friend class tst_QToolButton;
+public:
+ void initStyleOption(QStyleOptionToolButton *option) const override
+ {
+ QToolButton::initStyleOption(option);
+ }
+};
+
+
tst_QToolButton::tst_QToolButton()
{
}
@@ -150,16 +161,6 @@ void tst_QToolButton::triggered()
void tst_QToolButton::collapseTextOnPriority()
{
- class MyToolButton : public QToolButton
- {
- friend class tst_QToolButton;
- public:
- void initStyleOption(QStyleOptionToolButton *option)
- {
- QToolButton::initStyleOption(option);
- }
- };
-
MyToolButton button;
button.setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
QAction action(button.style()->standardIcon(QStyle::SP_ArrowBack), "test", 0);
@@ -178,16 +179,6 @@ void tst_QToolButton::task230994_iconSize()
{
//we check that the iconsize returned bu initStyleOption is valid
//when the toolbutton has no parent
- class MyToolButton : public QToolButton
- {
- friend class tst_QToolButton;
- public:
- void initStyleOption(QStyleOptionToolButton *option)
- {
- QToolButton::initStyleOption(option);
- }
- };
-
MyToolButton button;
QStyleOptionToolButton option;
button.initStyleOption(&option);