diff options
author | Sona Kurazyan <sona.kurazyan@qt.io> | 2019-07-23 15:26:19 +0200 |
---|---|---|
committer | Sona Kurazyan <sona.kurazyan@qt.io> | 2019-08-01 17:04:13 +0000 |
commit | 376715f1a57209cbb19502954a37939e2d6d88c6 (patch) | |
tree | 83786e4d39be7ce6f6ce3897d8fad8aab899b9f6 | |
parent | bd2c8353b44a1e63b84852ec9adeed78dbfab312 (diff) | |
download | qtbase-376715f1a57209cbb19502954a37939e2d6d88c6.tar.gz |
Remove usages of deprecated APIs of qtbase/widgets
- Replace the usages of deprecated APIs by corresponding
alternatives in the library code and documentation.
- Build docs for deprecated APIs conditionally, based on deprecation
version. Remove the docs of methods deprecated since 5.0.0, these
methods are not compiled anymore.
- Modify the tests to make them build when deprecated APIs disabled:
* Make the the parts of the tests testing the deprecated APIs to
be compiled conditionally, only when the corresponding methods
are enabled.
* If the test-case tests only the deprecated API, but not the
corresponding replacement, add tests for the replacement
Task-number: QTBUG-76491
Task-number: QTBUG-76540
Task-number: QTBUG-76541
Change-Id: I6aaf0a1369c479fb880369a38f2b8e1e86b46934
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
21 files changed, 120 insertions, 108 deletions
diff --git a/examples/widgets/dialogs/standarddialogs/dialog.cpp b/examples/widgets/dialogs/standarddialogs/dialog.cpp index c91a594490..df77d03567 100644 --- a/examples/widgets/dialogs/standarddialogs/dialog.cpp +++ b/examples/widgets/dialogs/standarddialogs/dialog.cpp @@ -317,7 +317,7 @@ void Dialog::setInteger() { //! [0] bool ok; - int i = QInputDialog::getInt(this, tr("QInputDialog::getInteger()"), + int i = QInputDialog::getInt(this, tr("QInputDialog::getInt()"), tr("Percentage:"), 25, 0, 100, 1, &ok); if (ok) integerLabel->setText(tr("%1%").arg(i)); diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp index 65708fa1ca..ca30c72db5 100644 --- a/src/widgets/graphicsview/qgraphicsitem.cpp +++ b/src/widgets/graphicsview/qgraphicsitem.cpp @@ -449,8 +449,8 @@ \value ItemSendsGeometryChanges The item enables itemChange() notifications for ItemPositionChange, ItemPositionHasChanged, - ItemMatrixChange, ItemTransformChange, ItemTransformHasChanged, - ItemRotationChange, ItemRotationHasChanged, ItemScaleChange, ItemScaleHasChanged, + ItemTransformChange, ItemTransformHasChanged, ItemRotationChange, + ItemRotationHasChanged, ItemScaleChange, ItemScaleHasChanged, ItemTransformOriginPointChange, and ItemTransformOriginPointHasChanged. For performance reasons, these notifications are disabled by default. You must enable this flag to receive notifications for position and transform diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp index be80843b07..c4766a74bd 100644 --- a/src/widgets/itemviews/qheaderview.cpp +++ b/src/widgets/itemviews/qheaderview.cpp @@ -189,7 +189,7 @@ static const int maxSizeSection = 1048575; // since section size is in a bitfiel The following values are obsolete: \value Custom Use Fixed instead. - \sa setResizeMode(), setSectionResizeMode(), stretchLastSection, minimumSectionSize + \sa setSectionResizeMode(), stretchLastSection, minimumSectionSize */ /*! @@ -880,7 +880,7 @@ void QHeaderView::swapSections(int first, int second) size equal to zero is however not recommended. In that situation hideSection should be used instead. - \sa sectionResized(), resizeMode(), sectionSize(), hideSection() + \sa sectionResized(), sectionSize(), hideSection() */ void QHeaderView::resizeSection(int logical, int size) @@ -960,7 +960,7 @@ void QHeaderView::resizeSection(int logical, int size) Resizes the sections according to the given \a mode, ignoring the current resize mode. - \sa resizeMode(), sectionResized() + \sa sectionResized() */ void QHeaderView::resizeSections(QHeaderView::ResizeMode mode) @@ -1139,16 +1139,6 @@ void QHeaderView::setSectionsMovable(bool movable) d->movableSections = movable; } -// ### Qt 6 - remove this obsolete function -/*! - \obsolete - \fn void QHeaderView::setMovable(bool movable) - - Use setSectionsMovable instead. - - \sa setSectionsMovable() -*/ - /*! \since 5.0 @@ -1167,16 +1157,6 @@ bool QHeaderView::sectionsMovable() const return d->movableSections; } -// ### Qt 6 - remove this obsolete function -/*! - \obsolete - \fn bool QHeaderView::isMovable() const - - Use sectionsMovable instead. - - \sa sectionsMovable() -*/ - /*! \property QHeaderView::firstSectionMovable \brief Whether the first column can be moved by the user @@ -1223,16 +1203,6 @@ void QHeaderView::setSectionsClickable(bool clickable) d->clickableSections = clickable; } -// ### Qt 6 - remove this obsolete function -/*! - \obsolete - \fn void QHeaderView::setClickable(bool clickable) - - Use setSectionsClickable instead. - - \sa setSectionsClickable() -*/ - /*! \since 5.0 @@ -1249,16 +1219,6 @@ bool QHeaderView::sectionsClickable() const return d->clickableSections; } -// ### Qt 6 - remove this obsolete function -/*! - \obsolete - \fn bool QHeaderView::isClickable() const - - Use sectionsClickable instead. - - \sa sectionsClickable() -*/ - void QHeaderView::setHighlightSections(bool highlight) { Q_D(QHeaderView); @@ -1277,7 +1237,7 @@ bool QHeaderView::highlightSections() const Sets the constraints on how the header can be resized to those described by the given \a mode. - \sa resizeMode(), length(), sectionResized() + \sa length(), sectionResized() */ void QHeaderView::setSectionResizeMode(ResizeMode mode) @@ -1327,26 +1287,6 @@ void QHeaderView::setSectionResizeMode(int logicalIndex, ResizeMode mode) d->doDelayedResizeSections(); // section sizes may change as a result of the new mode } -// ### Qt 6 - remove this obsolete function -/*! - \overload - \obsolete - \fn void QHeaderView::setResizeMode(int logicalIndex, ResizeMode mode) - - Use setSectionResizeMode instead. - - \sa setSectionResizeMode() -*/ - -/*! - \obsolete - \fn void QHeaderView::setResizeMode(ResizeMode mode) - - Use setSectionResizeMode instead. - - \sa setSectionResizeMode() -*/ - /*! \since 5.0 @@ -1407,16 +1347,6 @@ int QHeaderView::resizeContentsPrecision() const return d->resizeContentsPrecision; } -// ### Qt 6 - remove this obsolete function -/*! - \obsolete - \fn QHeaderView::ResizeMode QHeaderView::resizeMode(int logicalIndex) const - - Use sectionResizeMode instead. - - \sa sectionResizeMode() -*/ - /*! \since 4.1 @@ -1424,7 +1354,7 @@ int QHeaderView::resizeContentsPrecision() const views, this can be used to see if the headerview needs to resize the sections when the view's geometry changes. - \sa stretchLastSection, resizeMode() + \sa stretchLastSection */ int QHeaderView::stretchSectionCount() const diff --git a/src/widgets/itemviews/qlistwidget.cpp b/src/widgets/itemviews/qlistwidget.cpp index 37bb370e73..e7dcfac403 100644 --- a/src/widgets/itemviews/qlistwidget.cpp +++ b/src/widgets/itemviews/qlistwidget.cpp @@ -930,12 +930,14 @@ QDataStream &operator>>(QDataStream &in, QListWidgetItem &item) \sa Qt::AlignmentFlag */ +#if QT_DEPRECATED_SINCE(5, 13) /*! \fn QColor QListWidgetItem::backgroundColor() const \obsolete This function is deprecated. Use background() instead. */ +#endif /*! \fn QBrush QListWidgetItem::background() const @@ -946,6 +948,7 @@ QDataStream &operator>>(QDataStream &in, QListWidgetItem &item) \sa setBackground(), foreground() */ +#if QT_DEPRECATED_SINCE(5, 13) /*! \fn QColor QListWidgetItem::textColor() const \obsolete @@ -954,6 +957,7 @@ QDataStream &operator>>(QDataStream &in, QListWidgetItem &item) This function is deprecated. Use foreground() instead. */ +#endif /*! \fn QBrush QListWidgetItem::foreground() const @@ -1119,12 +1123,14 @@ void QListWidgetItem::setFlags(Qt::ItemFlags aflags) \sa background(), setForeground() */ +#if QT_DEPRECATED_SINCE(5, 13) /*! \fn void QListWidgetItem::setTextColor(const QColor &color) \obsolete This function is deprecated. Use setForeground() instead. */ +#endif /*! \fn void QListWidgetItem::setForeground(const QBrush &brush) diff --git a/src/widgets/itemviews/qtablewidget.cpp b/src/widgets/itemviews/qtablewidget.cpp index 0fb9e28385..a25a582881 100644 --- a/src/widgets/itemviews/qtablewidget.cpp +++ b/src/widgets/itemviews/qtablewidget.cpp @@ -1251,6 +1251,7 @@ void QTableWidgetItem::setFlags(Qt::ItemFlags aflags) \sa font(), setText(), setForeground() */ +#if QT_DEPRECATED_SINCE(5, 13) /*! \fn QColor QTableWidgetItem::backgroundColor() const \obsolete @@ -1264,6 +1265,7 @@ void QTableWidgetItem::setFlags(Qt::ItemFlags aflags) This function is deprecated. Use setBackground() instead. */ +#endif /*! \fn QBrush QTableWidgetItem::background() const @@ -1283,6 +1285,7 @@ void QTableWidgetItem::setFlags(Qt::ItemFlags aflags) \sa setForeground() */ +#if QT_DEPRECATED_SINCE(5, 13) /*! \fn QColor QTableWidgetItem::textColor() const \obsolete @@ -1296,6 +1299,7 @@ void QTableWidgetItem::setFlags(Qt::ItemFlags aflags) This function is deprecated. Use setForeground() instead. */ +#endif /*! \fn QBrush QTableWidgetItem::foreground() const diff --git a/src/widgets/itemviews/qtreewidget.cpp b/src/widgets/itemviews/qtreewidget.cpp index d2dc91b18c..d285ad6d28 100644 --- a/src/widgets/itemviews/qtreewidget.cpp +++ b/src/widgets/itemviews/qtreewidget.cpp @@ -1251,6 +1251,7 @@ bool QTreeWidgetItem::isFirstColumnSpanned() const \sa font(), setText(), setForeground() */ +#if QT_DEPRECATED_SINCE(5, 13) /*! \fn QColor QTreeWidgetItem::backgroundColor(int column) const \obsolete @@ -1264,6 +1265,7 @@ bool QTreeWidgetItem::isFirstColumnSpanned() const This function is deprecated. Use setBackground() instead. */ +#endif /*! \fn QBrush QTreeWidgetItem::background(int column) const @@ -1284,6 +1286,7 @@ bool QTreeWidgetItem::isFirstColumnSpanned() const \sa setForeground() */ +#if QT_DEPRECATED_SINCE(5, 13) /*! \fn QColor QTreeWidgetItem::textColor(int column) const \obsolete @@ -1297,6 +1300,7 @@ bool QTreeWidgetItem::isFirstColumnSpanned() const This function is deprecated. Use setForeground() instead. */ +#endif /*! \fn QBrush QTreeWidgetItem::foreground(int column) const diff --git a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp index c840dabc1a..a494d7119a 100644 --- a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp +++ b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp @@ -52,7 +52,9 @@ class DummyDialog : public QDialog { public: DummyDialog(): QDialog() {} +#if QT_DEPRECATED_SINCE(5, 13) using QDialog::showExtension; +#endif }; class tst_QDialog : public QObject @@ -64,8 +66,10 @@ public: private slots: void cleanup(); void getSetCheck(); +#if QT_DEPRECATED_SINCE(5, 13) void showExtension_data(); void showExtension(); +#endif void defaultButtons(); void showMaximized(); void showMinimized(); @@ -76,6 +80,9 @@ private slots: void deleteInExec(); #if QT_CONFIG(sizegrip) void showSizeGrip(); +#if QT_DEPRECATED_SINCE(5, 13) + void showSizeGrip_deprecated(); +#endif #endif void setVisible(); void reject(); @@ -89,6 +96,7 @@ private slots: void tst_QDialog::getSetCheck() { QDialog obj1; +#if QT_DEPRECATED_SINCE(5, 13) // QWidget* QDialog::extension() // void QDialog::setExtension(QWidget*) QWidget *var1 = new QWidget; @@ -97,6 +105,7 @@ void tst_QDialog::getSetCheck() obj1.setExtension((QWidget *)0); QCOMPARE((QWidget *)0, obj1.extension()); // No delete var1, since setExtension takes ownership +#endif // int QDialog::result() // void QDialog::setResult(int) @@ -146,6 +155,7 @@ void tst_QDialog::cleanup() QVERIFY(QApplication::topLevelWidgets().isEmpty()); } +#if QT_DEPRECATED_SINCE(5, 13) void tst_QDialog::showExtension_data() { QTest::addColumn<QSize>("dlgSize"); @@ -197,6 +207,7 @@ void tst_QDialog::showExtension() testWidget.setExtension( 0 ); } +#endif void tst_QDialog::defaultButtons() { @@ -422,9 +433,37 @@ void tst_QDialog::deleteInExec() } #if QT_CONFIG(sizegrip) + // From Task 124269 void tst_QDialog::showSizeGrip() { + QDialog dialog(nullptr); + dialog.show(); + QWidget *ext = new QWidget(&dialog); + QVERIFY(!dialog.isSizeGripEnabled()); + + dialog.setSizeGripEnabled(true); + QPointer<QSizeGrip> sizeGrip = dialog.findChild<QSizeGrip *>(); + QVERIFY(sizeGrip); + QVERIFY(sizeGrip->isVisible()); + QVERIFY(dialog.isSizeGripEnabled()); + + dialog.setSizeGripEnabled(false); + QVERIFY(!dialog.isSizeGripEnabled()); + + dialog.setSizeGripEnabled(true); + sizeGrip = dialog.findChild<QSizeGrip *>(); + QVERIFY(sizeGrip); + QVERIFY(sizeGrip->isVisible()); + sizeGrip->hide(); + dialog.hide(); + dialog.show(); + QVERIFY(!sizeGrip->isVisible()); +} + +#if QT_DEPRECATED_SINCE(5, 13) +void tst_QDialog::showSizeGrip_deprecated() +{ QDialog dialog(0); dialog.show(); QWidget *ext = new QWidget(&dialog); @@ -476,7 +515,9 @@ void tst_QDialog::showSizeGrip() dialog.show(); QVERIFY(!sizeGrip->isVisible()); } -#endif +#endif // QT_DEPRECATED_SINCE(5, 13) + +#endif // QT_CONFIG(sizegrip) void tst_QDialog::setVisible() { diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp index f7482bae45..2131e45f29 100644 --- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp +++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp @@ -800,7 +800,10 @@ void tst_QFiledialog::isReadOnly() QAction* renameAction = fd.findChild<QAction*>("qt_rename_action"); QAction* deleteAction = fd.findChild<QAction*>("qt_delete_action"); +#if QT_DEPRECATED_SINCE(5, 13) QCOMPARE(fd.isReadOnly(), false); +#endif + QCOMPARE(fd.testOption(QFileDialog::ReadOnly), false); // This is dependent upon the file/dir, find cross platform way to test //fd.setDirectory(QDir::home()); diff --git a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp index 869418371c..40eff1e4c3 100644 --- a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp +++ b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp @@ -378,24 +378,24 @@ void tst_QFileDialog2::task143519_deleteAndRenameActionBehavior() // defaults QVERIFY(openContextMenu(fd)); QCOMPARE(fd.selectedFiles(), QStringList(ctx.file.fileName())); - QCOMPARE(rm->isEnabled(), !fd.isReadOnly()); - QCOMPARE(mv->isEnabled(), !fd.isReadOnly()); + QCOMPARE(rm->isEnabled(), !fd.testOption(QFileDialog::ReadOnly)); + QCOMPARE(mv->isEnabled(), !fd.testOption(QFileDialog::ReadOnly)); // change to non-defaults: - fd.setReadOnly(!fd.isReadOnly()); + fd.setOption(QFileDialog::ReadOnly, !fd.testOption(QFileDialog::ReadOnly)); QVERIFY(openContextMenu(fd)); QCOMPARE(fd.selectedFiles().size(), 1); - QCOMPARE(rm->isEnabled(), !fd.isReadOnly()); - QCOMPARE(mv->isEnabled(), !fd.isReadOnly()); + QCOMPARE(rm->isEnabled(), !fd.testOption(QFileDialog::ReadOnly)); + QCOMPARE(mv->isEnabled(), !fd.testOption(QFileDialog::ReadOnly)); // and changed back to defaults: - fd.setReadOnly(!fd.isReadOnly()); + fd.setOption(QFileDialog::ReadOnly, !fd.testOption(QFileDialog::ReadOnly)); QVERIFY(openContextMenu(fd)); QCOMPARE(fd.selectedFiles().size(), 1); - QCOMPARE(rm->isEnabled(), !fd.isReadOnly()); - QCOMPARE(mv->isEnabled(), !fd.isReadOnly()); + QCOMPARE(rm->isEnabled(), !fd.testOption(QFileDialog::ReadOnly)); + QCOMPARE(mv->isEnabled(), !fd.testOption(QFileDialog::ReadOnly)); } #endif // !QT_NO_CONTEXTMENU && !QT_NO_MENU diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp index 432d8d75b7..7b914512ab 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp @@ -4441,12 +4441,14 @@ protected: case QGraphicsItem::ItemPositionHasChanged: break; case QGraphicsItem::ItemMatrixChange: { +#if QT_DEPRECATED_SINCE(5, 13) QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED QVariant variant; variant.setValue<QMatrix>(matrix()); oldValues << variant; QT_WARNING_POP +#endif } break; case QGraphicsItem::ItemTransformChange: { @@ -4566,6 +4568,7 @@ void tst_QGraphicsItem::itemChange() QCOMPARE(tester.oldValues.last(), QVariant(true)); QCOMPARE(tester.isEnabled(), true); } +#if QT_DEPRECATED_SINCE(5, 13) { QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED // QDesktopWidget::screen() @@ -4585,6 +4588,7 @@ QT_WARNING_DISABLE_DEPRECATED // QDesktopWidget::screen() QCOMPARE(tester.matrix(), QMatrix().rotate(90)); QT_WARNING_POP } +#endif { tester.resetTransform(); ++changeCount; diff --git a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp index 8dd9d7c428..00bde3cb25 100644 --- a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp +++ b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp @@ -194,7 +194,7 @@ void tst_QBoxLayout::setGeometry() setFrameless(&toplevel); QWidget w(&toplevel); QVBoxLayout *lay = new QVBoxLayout; - lay->setMargin(0); + lay->setContentsMargins(0, 0, 0, 0); lay->setSpacing(0); QHBoxLayout *lay2 = new QHBoxLayout; QDial *dial = new QDial; @@ -271,7 +271,7 @@ void tst_QBoxLayout::widgetSurplus() QDialog window; QScopedPointer<MarginEatingStyle> marginEater(new MarginEatingStyle); QVBoxLayout *vbox = new QVBoxLayout(&window); - vbox->setMargin(0); + vbox->setContentsMargins(0, 0, 0, 0); vbox->setSpacing(0); QLabel *hiddenLabel = new QLabel(tr("Invisible label")); diff --git a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp index 5e0327319b..1d63d140fb 100644 --- a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp +++ b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp @@ -219,9 +219,9 @@ void tst_QGridLayout::badDistributionBug() QDialog dialog; Ui::SortDialog ui; ui.setupUi(&dialog); - ui.gridLayout->setMargin(0); + ui.gridLayout->setContentsMargins(0, 0, 0, 0); ui.gridLayout->setSpacing(0); - ui.vboxLayout->setMargin(0); + ui.vboxLayout->setContentsMargins(0, 0, 0, 0); ui.vboxLayout->setSpacing(0); ui.okButton->setFixedHeight(20); ui.moreButton->setFixedHeight(20); @@ -237,7 +237,7 @@ void tst_QGridLayout::setMinAndMaxSize() QWidget widget; setFrameless(&widget); QGridLayout layout(&widget); - layout.setMargin(0); + layout.setContentsMargins(0, 0, 0, 0); layout.setSpacing(0); layout.setSizeConstraint(QLayout::SetMinAndMaxSize); widget.show(); @@ -396,7 +396,7 @@ void tst_QGridLayout::spacingAndSpacers() QWidget widget; setFrameless(&widget); QGridLayout layout(&widget); - layout.setMargin(0); + layout.setContentsMargins(0, 0, 0, 0); layout.setSpacing(0); widget.show(); @@ -1541,7 +1541,7 @@ void tst_QGridLayout::spacerWithSpacing() QWidget window; QGridLayout layout(&window); layout.setSpacing(1); - layout.setMargin(0); + layout.setContentsMargins(0, 0, 0, 0); populate(&layout, 0, i); populate(&layout, 1, j); populate(&layout, 2, k); @@ -1651,7 +1651,7 @@ void tst_QGridLayout::taskQTBUG_52357_spacingWhenItemIsHidden() QWidget widget; setFrameless(&widget); QGridLayout layout(&widget); - layout.setMargin(0); + layout.setContentsMargins(0, 0, 0, 0); layout.setSpacing(5); QPushButton button1; layout.addWidget(&button1, 0, 0); diff --git a/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp b/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp index 936f581d89..140a367afe 100644 --- a/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp +++ b/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp @@ -308,7 +308,7 @@ void tst_QLayout::controlTypes2() { QWidget main; QVBoxLayout *const layout = new QVBoxLayout(&main); - layout->setMargin(0); + layout->setContentsMargins(0, 0, 0, 0); QComboBox *combo = new QComboBox(&main); layout->addWidget(combo); QCOMPARE(layout->controlTypes(), QSizePolicy::ComboBox); @@ -319,7 +319,7 @@ void tst_QLayout::adjustSizeShouldMakeSureLayoutIsActivated() QWidget main; QVBoxLayout *const layout = new QVBoxLayout(&main); - layout->setMargin(0); + layout->setContentsMargins(0, 0, 0, 0); SizeHinterFrame *frame = new SizeHinterFrame(QSize(200, 10), QSize(200, 8)); frame->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); layout->addWidget(frame); diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 5465bd5518..bfc2631842 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -8073,7 +8073,7 @@ public: sp.setHeightForWidth(hfwLayout); QVBoxLayout *vbox = new QVBoxLayout; - vbox->setMargin(0); + vbox->setContentsMargins(0, 0, 0, 0); vbox->addWidget(new ASWidget(sizeHint + QSize(30, 20), sp, false, false)); setLayout(vbox); } @@ -10120,7 +10120,7 @@ void tst_QWidget::grabMouse() w.setObjectName(QLatin1String("tst_qwidget_grabMouse")); w.setWindowTitle(w.objectName()); QLayout *layout = new QVBoxLayout(&w); - layout->setMargin(50); + layout->setContentsMargins(50, 50, 50, 50); GrabLoggerWidget *grabber = new GrabLoggerWidget(&log, &w); const QString grabberObjectName = QLatin1String("tst_qwidget_grabMouse_grabber"); grabber->setObjectName(grabberObjectName); diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp index 8a46211714..4e16edaca8 100644 --- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp @@ -254,12 +254,22 @@ void tst_QComboBox::getSetCheck() obj1.setMaxCount(INT_MAX); QCOMPARE(INT_MAX, obj1.maxCount()); + // QCompleter *QComboBox::completer() + // void QComboBox::setCompleter(QCompleter *) + obj1.setCompleter(nullptr); + QCOMPARE(nullptr, obj1.completer()); + QCompleter completer; + obj1.setCompleter(&completer); + QVERIFY(obj1.completer() == nullptr); // no QLineEdit is set + +#if QT_DEPRECATED_SINCE(5, 13) // bool QComboBox::autoCompletion() // void QComboBox::setAutoCompletion(bool) obj1.setAutoCompletion(false); QCOMPARE(false, obj1.autoCompletion()); obj1.setAutoCompletion(true); QCOMPARE(true, obj1.autoCompletion()); +#endif // bool QComboBox::duplicatesEnabled() // void QComboBox::setDuplicatesEnabled(bool) @@ -317,6 +327,9 @@ void tst_QComboBox::getSetCheck() QCOMPARE(var8, obj1.lineEdit()); // delete var8; // No delete, since QComboBox takes ownership + // After setting a line edit, completer() should not return nullptr anymore + QVERIFY(obj1.completer() != nullptr); + // const QValidator * QComboBox::validator() // void QComboBox::setValidator(const QValidator *) QIntValidator *var9 = new QIntValidator(0); @@ -777,7 +790,9 @@ void tst_QComboBox::virtualAutocompletion() QVERIFY(QTest::qWaitForWindowExposed(&topLevel)); QComboBox *testWidget = topLevel.comboBox(); testWidget->clear(); +#if QT_DEPRECATED_SINCE(5, 13) testWidget->setAutoCompletion(true); +#endif testWidget->addItem("Foo"); testWidget->addItem("Bar"); testWidget->addItem("Boat"); @@ -837,7 +852,9 @@ void tst_QComboBox::autoCompletionCaseSensitivity() QCOMPARE(qApp->focusWidget(), (QWidget *)testWidget); testWidget->clear(); +#if QT_DEPRECATED_SINCE(5, 13) testWidget->setAutoCompletion(true); +#endif testWidget->addItem("Cow"); testWidget->addItem("irrelevant1"); testWidget->addItem("aww"); @@ -3054,7 +3071,9 @@ void tst_QComboBox::task_QTBUG_31146_popupCompletion() { QComboBox comboBox; comboBox.setEditable(true); +#if QT_DEPRECATED_SINCE(5, 13) comboBox.setAutoCompletion(true); +#endif comboBox.setInsertPolicy(QComboBox::NoInsert); comboBox.completer()->setCaseSensitivity(Qt::CaseInsensitive); comboBox.completer()->setCompletionMode(QCompleter::PopupCompletion); diff --git a/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp b/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp index 34862f6810..f599ac73c6 100644 --- a/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp +++ b/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp @@ -461,7 +461,7 @@ void tst_QLabel::unicodeText() QVBoxLayout *layout = new QVBoxLayout(); QLabel *label = new QLabel(text, &frame); layout->addWidget(label); - layout->setMargin(8); + layout->setContentsMargins(8, 8, 8, 8); frame.setLayout(layout); frame.show(); QVERIFY(QTest::qWaitForWindowExposed(&frame)); diff --git a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp index 046899ce05..b8abd78657 100644 --- a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp +++ b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp @@ -880,7 +880,7 @@ void tst_QMdiArea::minimumSizeHint() { QMdiArea workspace; workspace.show(); - QSize expectedSize(workspace.style()->pixelMetric(QStyle::PM_MDIMinimizedWidth), + QSize expectedSize(workspace.style()->pixelMetric(QStyle::PM_MdiSubWindowMinimizedWidth), workspace.style()->pixelMetric(QStyle::PM_TitleBarHeight)); qApp->processEvents(); QAbstractScrollArea dummyScrollArea; diff --git a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp index 2b59a227b3..b8891fab95 100644 --- a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp +++ b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp @@ -613,7 +613,7 @@ void tst_QMdiSubWindow::showShaded() // Calculate mouse position for bottom right corner and simulate a // vertical resize with the mouse. - int offset = window->style()->pixelMetric(QStyle::PM_MDIFrameWidth) / 2; + int offset = window->style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth) / 2; QPoint mousePosition(window->width() - qMax(offset, 2), window->height() - qMax(offset, 2)); QWidget *mouseReceiver = nullptr; #ifdef Q_OS_MAC @@ -759,7 +759,7 @@ void tst_QMdiSubWindow::setOpaqueResizeAndMove() QTRY_COMPARE(priv->resizeTimerId, -1); // Enter resize mode. - int offset = window->style()->pixelMetric(QStyle::PM_MDIFrameWidth) / 2; + int offset = window->style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth) / 2; QPoint mousePosition(mouseReceiver->width() - qMax(offset, 2), mouseReceiver->height() - qMax(offset, 2)); sendMouseMove(mouseReceiver, mousePosition, Qt::NoButton); sendMousePress(mouseReceiver, mousePosition); @@ -1762,7 +1762,8 @@ void tst_QMdiSubWindow::fixedMinMaxSize() int minimizedHeight = subWindow->style()->pixelMetric(QStyle::PM_TitleBarHeight, &options); if (!subWindow->style()->styleHint(QStyle::SH_TitleBar_NoBorder, &options, subWindow)) minimizedHeight += 8; - int minimizedWidth = subWindow->style()->pixelMetric(QStyle::PM_MDIMinimizedWidth, &options); + int minimizedWidth = subWindow->style()->pixelMetric(QStyle::PM_MdiSubWindowMinimizedWidth, + &options); const QSize minimizedSize = QSize(minimizedWidth, minimizedHeight); // Even though the sub window has a minimum size set, it should be possible diff --git a/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp b/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp index 8b45ac20b7..cbeb77a25e 100644 --- a/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp +++ b/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp @@ -599,7 +599,7 @@ void tst_QSplitter::testShowHide() QWidget widget(&topLevel); widget.resize(400 + split->handleWidth(), 200); QVBoxLayout *lay=new QVBoxLayout(&widget); - lay->setMargin(0); + lay->setContentsMargins(0, 0, 0, 0); lay->setSpacing(0); split->addWidget(new QWidget); split->addWidget(new QWidget); diff --git a/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp b/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp index cbf5196bb9..feade7d443 100644 --- a/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp +++ b/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp @@ -620,7 +620,7 @@ void tst_QTabWidget::heightForWidth() QWidget *window = new QWidget; QVBoxLayout *lay = new QVBoxLayout(window); - lay->setMargin(0); + lay->setContentsMargins(0, 0, 0, 0); lay->setSpacing(0); QTabWidget *tabWid = new QTabWidget(window); QWidget *w = new QWidget; @@ -637,7 +637,7 @@ void tst_QTabWidget::heightForWidth() ); label->setWordWrap(true); lay2->addWidget(label); - lay2->setMargin(0); + lay2->setContentsMargins(0, 0, 0, 0); lay->addWidget(tabWid); int h = window->heightForWidth(160); diff --git a/tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/chipTest/chip.cpp b/tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/chipTest/chip.cpp index 57ab62b1c3..2277ae0f14 100644 --- a/tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/chipTest/chip.cpp +++ b/tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/chipTest/chip.cpp @@ -38,7 +38,7 @@ Chip::Chip(const QColor &color, int x, int y) setZValue((x + y) % 2); setFlags(ItemIsSelectable | ItemIsMovable); - setAcceptsHoverEvents(true); + setAcceptHoverEvents(true); } QRectF Chip::boundingRect() const |