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>
This commit is contained in:
Sona Kurazyan 2019-07-23 15:26:19 +02:00
parent bd2c8353b4
commit 376715f1a5
21 changed files with 120 additions and 108 deletions

View File

@ -317,7 +317,7 @@ void Dialog::setInteger()
{ {
//! [0] //! [0]
bool ok; 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); tr("Percentage:"), 25, 0, 100, 1, &ok);
if (ok) if (ok)
integerLabel->setText(tr("%1%").arg(i)); integerLabel->setText(tr("%1%").arg(i));

View File

@ -449,8 +449,8 @@
\value ItemSendsGeometryChanges The item enables itemChange() \value ItemSendsGeometryChanges The item enables itemChange()
notifications for ItemPositionChange, ItemPositionHasChanged, notifications for ItemPositionChange, ItemPositionHasChanged,
ItemMatrixChange, ItemTransformChange, ItemTransformHasChanged, ItemTransformChange, ItemTransformHasChanged, ItemRotationChange,
ItemRotationChange, ItemRotationHasChanged, ItemScaleChange, ItemScaleHasChanged, ItemRotationHasChanged, ItemScaleChange, ItemScaleHasChanged,
ItemTransformOriginPointChange, and ItemTransformOriginPointHasChanged. For ItemTransformOriginPointChange, and ItemTransformOriginPointHasChanged. For
performance reasons, these notifications are disabled by default. You must performance reasons, these notifications are disabled by default. You must
enable this flag to receive notifications for position and transform enable this flag to receive notifications for position and transform

View File

@ -189,7 +189,7 @@ static const int maxSizeSection = 1048575; // since section size is in a bitfiel
The following values are obsolete: The following values are obsolete:
\value Custom Use Fixed instead. \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 size equal to zero is however not recommended. In that situation hideSection
should be used instead. should be used instead.
\sa sectionResized(), resizeMode(), sectionSize(), hideSection() \sa sectionResized(), sectionSize(), hideSection()
*/ */
void QHeaderView::resizeSection(int logical, int size) 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 Resizes the sections according to the given \a mode, ignoring the current
resize mode. resize mode.
\sa resizeMode(), sectionResized() \sa sectionResized()
*/ */
void QHeaderView::resizeSections(QHeaderView::ResizeMode mode) void QHeaderView::resizeSections(QHeaderView::ResizeMode mode)
@ -1139,16 +1139,6 @@ void QHeaderView::setSectionsMovable(bool movable)
d->movableSections = 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 \since 5.0
@ -1167,16 +1157,6 @@ bool QHeaderView::sectionsMovable() const
return d->movableSections; return d->movableSections;
} }
// ### Qt 6 - remove this obsolete function
/*!
\obsolete
\fn bool QHeaderView::isMovable() const
Use sectionsMovable instead.
\sa sectionsMovable()
*/
/*! /*!
\property QHeaderView::firstSectionMovable \property QHeaderView::firstSectionMovable
\brief Whether the first column can be moved by the user \brief Whether the first column can be moved by the user
@ -1223,16 +1203,6 @@ void QHeaderView::setSectionsClickable(bool clickable)
d->clickableSections = 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 \since 5.0
@ -1249,16 +1219,6 @@ bool QHeaderView::sectionsClickable() const
return d->clickableSections; 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) void QHeaderView::setHighlightSections(bool highlight)
{ {
Q_D(QHeaderView); Q_D(QHeaderView);
@ -1277,7 +1237,7 @@ bool QHeaderView::highlightSections() const
Sets the constraints on how the header can be resized to those described Sets the constraints on how the header can be resized to those described
by the given \a mode. by the given \a mode.
\sa resizeMode(), length(), sectionResized() \sa length(), sectionResized()
*/ */
void QHeaderView::setSectionResizeMode(ResizeMode mode) 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 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 \since 5.0
@ -1407,16 +1347,6 @@ int QHeaderView::resizeContentsPrecision() const
return d->resizeContentsPrecision; 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 \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 views, this can be used to see if the headerview needs to resize the
sections when the view's geometry changes. sections when the view's geometry changes.
\sa stretchLastSection, resizeMode() \sa stretchLastSection
*/ */
int QHeaderView::stretchSectionCount() const int QHeaderView::stretchSectionCount() const

View File

@ -930,12 +930,14 @@ QDataStream &operator>>(QDataStream &in, QListWidgetItem &item)
\sa Qt::AlignmentFlag \sa Qt::AlignmentFlag
*/ */
#if QT_DEPRECATED_SINCE(5, 13)
/*! /*!
\fn QColor QListWidgetItem::backgroundColor() const \fn QColor QListWidgetItem::backgroundColor() const
\obsolete \obsolete
This function is deprecated. Use background() instead. This function is deprecated. Use background() instead.
*/ */
#endif
/*! /*!
\fn QBrush QListWidgetItem::background() const \fn QBrush QListWidgetItem::background() const
@ -946,6 +948,7 @@ QDataStream &operator>>(QDataStream &in, QListWidgetItem &item)
\sa setBackground(), foreground() \sa setBackground(), foreground()
*/ */
#if QT_DEPRECATED_SINCE(5, 13)
/*! /*!
\fn QColor QListWidgetItem::textColor() const \fn QColor QListWidgetItem::textColor() const
\obsolete \obsolete
@ -954,6 +957,7 @@ QDataStream &operator>>(QDataStream &in, QListWidgetItem &item)
This function is deprecated. Use foreground() instead. This function is deprecated. Use foreground() instead.
*/ */
#endif
/*! /*!
\fn QBrush QListWidgetItem::foreground() const \fn QBrush QListWidgetItem::foreground() const
@ -1119,12 +1123,14 @@ void QListWidgetItem::setFlags(Qt::ItemFlags aflags)
\sa background(), setForeground() \sa background(), setForeground()
*/ */
#if QT_DEPRECATED_SINCE(5, 13)
/*! /*!
\fn void QListWidgetItem::setTextColor(const QColor &color) \fn void QListWidgetItem::setTextColor(const QColor &color)
\obsolete \obsolete
This function is deprecated. Use setForeground() instead. This function is deprecated. Use setForeground() instead.
*/ */
#endif
/*! /*!
\fn void QListWidgetItem::setForeground(const QBrush &brush) \fn void QListWidgetItem::setForeground(const QBrush &brush)

View File

@ -1251,6 +1251,7 @@ void QTableWidgetItem::setFlags(Qt::ItemFlags aflags)
\sa font(), setText(), setForeground() \sa font(), setText(), setForeground()
*/ */
#if QT_DEPRECATED_SINCE(5, 13)
/*! /*!
\fn QColor QTableWidgetItem::backgroundColor() const \fn QColor QTableWidgetItem::backgroundColor() const
\obsolete \obsolete
@ -1264,6 +1265,7 @@ void QTableWidgetItem::setFlags(Qt::ItemFlags aflags)
This function is deprecated. Use setBackground() instead. This function is deprecated. Use setBackground() instead.
*/ */
#endif
/*! /*!
\fn QBrush QTableWidgetItem::background() const \fn QBrush QTableWidgetItem::background() const
@ -1283,6 +1285,7 @@ void QTableWidgetItem::setFlags(Qt::ItemFlags aflags)
\sa setForeground() \sa setForeground()
*/ */
#if QT_DEPRECATED_SINCE(5, 13)
/*! /*!
\fn QColor QTableWidgetItem::textColor() const \fn QColor QTableWidgetItem::textColor() const
\obsolete \obsolete
@ -1296,6 +1299,7 @@ void QTableWidgetItem::setFlags(Qt::ItemFlags aflags)
This function is deprecated. Use setForeground() instead. This function is deprecated. Use setForeground() instead.
*/ */
#endif
/*! /*!
\fn QBrush QTableWidgetItem::foreground() const \fn QBrush QTableWidgetItem::foreground() const

View File

@ -1251,6 +1251,7 @@ bool QTreeWidgetItem::isFirstColumnSpanned() const
\sa font(), setText(), setForeground() \sa font(), setText(), setForeground()
*/ */
#if QT_DEPRECATED_SINCE(5, 13)
/*! /*!
\fn QColor QTreeWidgetItem::backgroundColor(int column) const \fn QColor QTreeWidgetItem::backgroundColor(int column) const
\obsolete \obsolete
@ -1264,6 +1265,7 @@ bool QTreeWidgetItem::isFirstColumnSpanned() const
This function is deprecated. Use setBackground() instead. This function is deprecated. Use setBackground() instead.
*/ */
#endif
/*! /*!
\fn QBrush QTreeWidgetItem::background(int column) const \fn QBrush QTreeWidgetItem::background(int column) const
@ -1284,6 +1286,7 @@ bool QTreeWidgetItem::isFirstColumnSpanned() const
\sa setForeground() \sa setForeground()
*/ */
#if QT_DEPRECATED_SINCE(5, 13)
/*! /*!
\fn QColor QTreeWidgetItem::textColor(int column) const \fn QColor QTreeWidgetItem::textColor(int column) const
\obsolete \obsolete
@ -1297,6 +1300,7 @@ bool QTreeWidgetItem::isFirstColumnSpanned() const
This function is deprecated. Use setForeground() instead. This function is deprecated. Use setForeground() instead.
*/ */
#endif
/*! /*!
\fn QBrush QTreeWidgetItem::foreground(int column) const \fn QBrush QTreeWidgetItem::foreground(int column) const

View File

@ -52,7 +52,9 @@ class DummyDialog : public QDialog
{ {
public: public:
DummyDialog(): QDialog() {} DummyDialog(): QDialog() {}
#if QT_DEPRECATED_SINCE(5, 13)
using QDialog::showExtension; using QDialog::showExtension;
#endif
}; };
class tst_QDialog : public QObject class tst_QDialog : public QObject
@ -64,8 +66,10 @@ public:
private slots: private slots:
void cleanup(); void cleanup();
void getSetCheck(); void getSetCheck();
#if QT_DEPRECATED_SINCE(5, 13)
void showExtension_data(); void showExtension_data();
void showExtension(); void showExtension();
#endif
void defaultButtons(); void defaultButtons();
void showMaximized(); void showMaximized();
void showMinimized(); void showMinimized();
@ -76,6 +80,9 @@ private slots:
void deleteInExec(); void deleteInExec();
#if QT_CONFIG(sizegrip) #if QT_CONFIG(sizegrip)
void showSizeGrip(); void showSizeGrip();
#if QT_DEPRECATED_SINCE(5, 13)
void showSizeGrip_deprecated();
#endif
#endif #endif
void setVisible(); void setVisible();
void reject(); void reject();
@ -89,6 +96,7 @@ private slots:
void tst_QDialog::getSetCheck() void tst_QDialog::getSetCheck()
{ {
QDialog obj1; QDialog obj1;
#if QT_DEPRECATED_SINCE(5, 13)
// QWidget* QDialog::extension() // QWidget* QDialog::extension()
// void QDialog::setExtension(QWidget*) // void QDialog::setExtension(QWidget*)
QWidget *var1 = new QWidget; QWidget *var1 = new QWidget;
@ -97,6 +105,7 @@ void tst_QDialog::getSetCheck()
obj1.setExtension((QWidget *)0); obj1.setExtension((QWidget *)0);
QCOMPARE((QWidget *)0, obj1.extension()); QCOMPARE((QWidget *)0, obj1.extension());
// No delete var1, since setExtension takes ownership // No delete var1, since setExtension takes ownership
#endif
// int QDialog::result() // int QDialog::result()
// void QDialog::setResult(int) // void QDialog::setResult(int)
@ -146,6 +155,7 @@ void tst_QDialog::cleanup()
QVERIFY(QApplication::topLevelWidgets().isEmpty()); QVERIFY(QApplication::topLevelWidgets().isEmpty());
} }
#if QT_DEPRECATED_SINCE(5, 13)
void tst_QDialog::showExtension_data() void tst_QDialog::showExtension_data()
{ {
QTest::addColumn<QSize>("dlgSize"); QTest::addColumn<QSize>("dlgSize");
@ -197,6 +207,7 @@ void tst_QDialog::showExtension()
testWidget.setExtension( 0 ); testWidget.setExtension( 0 );
} }
#endif
void tst_QDialog::defaultButtons() void tst_QDialog::defaultButtons()
{ {
@ -422,8 +433,36 @@ void tst_QDialog::deleteInExec()
} }
#if QT_CONFIG(sizegrip) #if QT_CONFIG(sizegrip)
// From Task 124269 // From Task 124269
void tst_QDialog::showSizeGrip() 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); QDialog dialog(0);
dialog.show(); dialog.show();
@ -476,7 +515,9 @@ void tst_QDialog::showSizeGrip()
dialog.show(); dialog.show();
QVERIFY(!sizeGrip->isVisible()); QVERIFY(!sizeGrip->isVisible());
} }
#endif #endif // QT_DEPRECATED_SINCE(5, 13)
#endif // QT_CONFIG(sizegrip)
void tst_QDialog::setVisible() void tst_QDialog::setVisible()
{ {

View File

@ -800,7 +800,10 @@ void tst_QFiledialog::isReadOnly()
QAction* renameAction = fd.findChild<QAction*>("qt_rename_action"); QAction* renameAction = fd.findChild<QAction*>("qt_rename_action");
QAction* deleteAction = fd.findChild<QAction*>("qt_delete_action"); QAction* deleteAction = fd.findChild<QAction*>("qt_delete_action");
#if QT_DEPRECATED_SINCE(5, 13)
QCOMPARE(fd.isReadOnly(), false); QCOMPARE(fd.isReadOnly(), false);
#endif
QCOMPARE(fd.testOption(QFileDialog::ReadOnly), false);
// This is dependent upon the file/dir, find cross platform way to test // This is dependent upon the file/dir, find cross platform way to test
//fd.setDirectory(QDir::home()); //fd.setDirectory(QDir::home());

View File

@ -378,24 +378,24 @@ void tst_QFileDialog2::task143519_deleteAndRenameActionBehavior()
// defaults // defaults
QVERIFY(openContextMenu(fd)); QVERIFY(openContextMenu(fd));
QCOMPARE(fd.selectedFiles(), QStringList(ctx.file.fileName())); QCOMPARE(fd.selectedFiles(), QStringList(ctx.file.fileName()));
QCOMPARE(rm->isEnabled(), !fd.isReadOnly()); QCOMPARE(rm->isEnabled(), !fd.testOption(QFileDialog::ReadOnly));
QCOMPARE(mv->isEnabled(), !fd.isReadOnly()); QCOMPARE(mv->isEnabled(), !fd.testOption(QFileDialog::ReadOnly));
// change to non-defaults: // change to non-defaults:
fd.setReadOnly(!fd.isReadOnly()); fd.setOption(QFileDialog::ReadOnly, !fd.testOption(QFileDialog::ReadOnly));
QVERIFY(openContextMenu(fd)); QVERIFY(openContextMenu(fd));
QCOMPARE(fd.selectedFiles().size(), 1); QCOMPARE(fd.selectedFiles().size(), 1);
QCOMPARE(rm->isEnabled(), !fd.isReadOnly()); QCOMPARE(rm->isEnabled(), !fd.testOption(QFileDialog::ReadOnly));
QCOMPARE(mv->isEnabled(), !fd.isReadOnly()); QCOMPARE(mv->isEnabled(), !fd.testOption(QFileDialog::ReadOnly));
// and changed back to defaults: // and changed back to defaults:
fd.setReadOnly(!fd.isReadOnly()); fd.setOption(QFileDialog::ReadOnly, !fd.testOption(QFileDialog::ReadOnly));
QVERIFY(openContextMenu(fd)); QVERIFY(openContextMenu(fd));
QCOMPARE(fd.selectedFiles().size(), 1); QCOMPARE(fd.selectedFiles().size(), 1);
QCOMPARE(rm->isEnabled(), !fd.isReadOnly()); QCOMPARE(rm->isEnabled(), !fd.testOption(QFileDialog::ReadOnly));
QCOMPARE(mv->isEnabled(), !fd.isReadOnly()); QCOMPARE(mv->isEnabled(), !fd.testOption(QFileDialog::ReadOnly));
} }
#endif // !QT_NO_CONTEXTMENU && !QT_NO_MENU #endif // !QT_NO_CONTEXTMENU && !QT_NO_MENU

View File

@ -4441,12 +4441,14 @@ protected:
case QGraphicsItem::ItemPositionHasChanged: case QGraphicsItem::ItemPositionHasChanged:
break; break;
case QGraphicsItem::ItemMatrixChange: { case QGraphicsItem::ItemMatrixChange: {
#if QT_DEPRECATED_SINCE(5, 13)
QT_WARNING_PUSH QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED QT_WARNING_DISABLE_DEPRECATED
QVariant variant; QVariant variant;
variant.setValue<QMatrix>(matrix()); variant.setValue<QMatrix>(matrix());
oldValues << variant; oldValues << variant;
QT_WARNING_POP QT_WARNING_POP
#endif
} }
break; break;
case QGraphicsItem::ItemTransformChange: { case QGraphicsItem::ItemTransformChange: {
@ -4566,6 +4568,7 @@ void tst_QGraphicsItem::itemChange()
QCOMPARE(tester.oldValues.last(), QVariant(true)); QCOMPARE(tester.oldValues.last(), QVariant(true));
QCOMPARE(tester.isEnabled(), true); QCOMPARE(tester.isEnabled(), true);
} }
#if QT_DEPRECATED_SINCE(5, 13)
{ {
QT_WARNING_PUSH QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED // QDesktopWidget::screen() QT_WARNING_DISABLE_DEPRECATED // QDesktopWidget::screen()
@ -4585,6 +4588,7 @@ QT_WARNING_DISABLE_DEPRECATED // QDesktopWidget::screen()
QCOMPARE(tester.matrix(), QMatrix().rotate(90)); QCOMPARE(tester.matrix(), QMatrix().rotate(90));
QT_WARNING_POP QT_WARNING_POP
} }
#endif
{ {
tester.resetTransform(); tester.resetTransform();
++changeCount; ++changeCount;

View File

@ -194,7 +194,7 @@ void tst_QBoxLayout::setGeometry()
setFrameless(&toplevel); setFrameless(&toplevel);
QWidget w(&toplevel); QWidget w(&toplevel);
QVBoxLayout *lay = new QVBoxLayout; QVBoxLayout *lay = new QVBoxLayout;
lay->setMargin(0); lay->setContentsMargins(0, 0, 0, 0);
lay->setSpacing(0); lay->setSpacing(0);
QHBoxLayout *lay2 = new QHBoxLayout; QHBoxLayout *lay2 = new QHBoxLayout;
QDial *dial = new QDial; QDial *dial = new QDial;
@ -271,7 +271,7 @@ void tst_QBoxLayout::widgetSurplus()
QDialog window; QDialog window;
QScopedPointer<MarginEatingStyle> marginEater(new MarginEatingStyle); QScopedPointer<MarginEatingStyle> marginEater(new MarginEatingStyle);
QVBoxLayout *vbox = new QVBoxLayout(&window); QVBoxLayout *vbox = new QVBoxLayout(&window);
vbox->setMargin(0); vbox->setContentsMargins(0, 0, 0, 0);
vbox->setSpacing(0); vbox->setSpacing(0);
QLabel *hiddenLabel = new QLabel(tr("Invisible label")); QLabel *hiddenLabel = new QLabel(tr("Invisible label"));

View File

@ -219,9 +219,9 @@ void tst_QGridLayout::badDistributionBug()
QDialog dialog; QDialog dialog;
Ui::SortDialog ui; Ui::SortDialog ui;
ui.setupUi(&dialog); ui.setupUi(&dialog);
ui.gridLayout->setMargin(0); ui.gridLayout->setContentsMargins(0, 0, 0, 0);
ui.gridLayout->setSpacing(0); ui.gridLayout->setSpacing(0);
ui.vboxLayout->setMargin(0); ui.vboxLayout->setContentsMargins(0, 0, 0, 0);
ui.vboxLayout->setSpacing(0); ui.vboxLayout->setSpacing(0);
ui.okButton->setFixedHeight(20); ui.okButton->setFixedHeight(20);
ui.moreButton->setFixedHeight(20); ui.moreButton->setFixedHeight(20);
@ -237,7 +237,7 @@ void tst_QGridLayout::setMinAndMaxSize()
QWidget widget; QWidget widget;
setFrameless(&widget); setFrameless(&widget);
QGridLayout layout(&widget); QGridLayout layout(&widget);
layout.setMargin(0); layout.setContentsMargins(0, 0, 0, 0);
layout.setSpacing(0); layout.setSpacing(0);
layout.setSizeConstraint(QLayout::SetMinAndMaxSize); layout.setSizeConstraint(QLayout::SetMinAndMaxSize);
widget.show(); widget.show();
@ -396,7 +396,7 @@ void tst_QGridLayout::spacingAndSpacers()
QWidget widget; QWidget widget;
setFrameless(&widget); setFrameless(&widget);
QGridLayout layout(&widget); QGridLayout layout(&widget);
layout.setMargin(0); layout.setContentsMargins(0, 0, 0, 0);
layout.setSpacing(0); layout.setSpacing(0);
widget.show(); widget.show();
@ -1541,7 +1541,7 @@ void tst_QGridLayout::spacerWithSpacing()
QWidget window; QWidget window;
QGridLayout layout(&window); QGridLayout layout(&window);
layout.setSpacing(1); layout.setSpacing(1);
layout.setMargin(0); layout.setContentsMargins(0, 0, 0, 0);
populate(&layout, 0, i); populate(&layout, 0, i);
populate(&layout, 1, j); populate(&layout, 1, j);
populate(&layout, 2, k); populate(&layout, 2, k);
@ -1651,7 +1651,7 @@ void tst_QGridLayout::taskQTBUG_52357_spacingWhenItemIsHidden()
QWidget widget; QWidget widget;
setFrameless(&widget); setFrameless(&widget);
QGridLayout layout(&widget); QGridLayout layout(&widget);
layout.setMargin(0); layout.setContentsMargins(0, 0, 0, 0);
layout.setSpacing(5); layout.setSpacing(5);
QPushButton button1; QPushButton button1;
layout.addWidget(&button1, 0, 0); layout.addWidget(&button1, 0, 0);

View File

@ -308,7 +308,7 @@ void tst_QLayout::controlTypes2()
{ {
QWidget main; QWidget main;
QVBoxLayout *const layout = new QVBoxLayout(&main); QVBoxLayout *const layout = new QVBoxLayout(&main);
layout->setMargin(0); layout->setContentsMargins(0, 0, 0, 0);
QComboBox *combo = new QComboBox(&main); QComboBox *combo = new QComboBox(&main);
layout->addWidget(combo); layout->addWidget(combo);
QCOMPARE(layout->controlTypes(), QSizePolicy::ComboBox); QCOMPARE(layout->controlTypes(), QSizePolicy::ComboBox);
@ -319,7 +319,7 @@ void tst_QLayout::adjustSizeShouldMakeSureLayoutIsActivated()
QWidget main; QWidget main;
QVBoxLayout *const layout = new QVBoxLayout(&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)); SizeHinterFrame *frame = new SizeHinterFrame(QSize(200, 10), QSize(200, 8));
frame->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); frame->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
layout->addWidget(frame); layout->addWidget(frame);

View File

@ -8073,7 +8073,7 @@ public:
sp.setHeightForWidth(hfwLayout); sp.setHeightForWidth(hfwLayout);
QVBoxLayout *vbox = new QVBoxLayout; QVBoxLayout *vbox = new QVBoxLayout;
vbox->setMargin(0); vbox->setContentsMargins(0, 0, 0, 0);
vbox->addWidget(new ASWidget(sizeHint + QSize(30, 20), sp, false, false)); vbox->addWidget(new ASWidget(sizeHint + QSize(30, 20), sp, false, false));
setLayout(vbox); setLayout(vbox);
} }
@ -10120,7 +10120,7 @@ void tst_QWidget::grabMouse()
w.setObjectName(QLatin1String("tst_qwidget_grabMouse")); w.setObjectName(QLatin1String("tst_qwidget_grabMouse"));
w.setWindowTitle(w.objectName()); w.setWindowTitle(w.objectName());
QLayout *layout = new QVBoxLayout(&w); QLayout *layout = new QVBoxLayout(&w);
layout->setMargin(50); layout->setContentsMargins(50, 50, 50, 50);
GrabLoggerWidget *grabber = new GrabLoggerWidget(&log, &w); GrabLoggerWidget *grabber = new GrabLoggerWidget(&log, &w);
const QString grabberObjectName = QLatin1String("tst_qwidget_grabMouse_grabber"); const QString grabberObjectName = QLatin1String("tst_qwidget_grabMouse_grabber");
grabber->setObjectName(grabberObjectName); grabber->setObjectName(grabberObjectName);

View File

@ -254,12 +254,22 @@ void tst_QComboBox::getSetCheck()
obj1.setMaxCount(INT_MAX); obj1.setMaxCount(INT_MAX);
QCOMPARE(INT_MAX, obj1.maxCount()); 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() // bool QComboBox::autoCompletion()
// void QComboBox::setAutoCompletion(bool) // void QComboBox::setAutoCompletion(bool)
obj1.setAutoCompletion(false); obj1.setAutoCompletion(false);
QCOMPARE(false, obj1.autoCompletion()); QCOMPARE(false, obj1.autoCompletion());
obj1.setAutoCompletion(true); obj1.setAutoCompletion(true);
QCOMPARE(true, obj1.autoCompletion()); QCOMPARE(true, obj1.autoCompletion());
#endif
// bool QComboBox::duplicatesEnabled() // bool QComboBox::duplicatesEnabled()
// void QComboBox::setDuplicatesEnabled(bool) // void QComboBox::setDuplicatesEnabled(bool)
@ -317,6 +327,9 @@ void tst_QComboBox::getSetCheck()
QCOMPARE(var8, obj1.lineEdit()); QCOMPARE(var8, obj1.lineEdit());
// delete var8; // No delete, since QComboBox takes ownership // 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() // const QValidator * QComboBox::validator()
// void QComboBox::setValidator(const QValidator *) // void QComboBox::setValidator(const QValidator *)
QIntValidator *var9 = new QIntValidator(0); QIntValidator *var9 = new QIntValidator(0);
@ -777,7 +790,9 @@ void tst_QComboBox::virtualAutocompletion()
QVERIFY(QTest::qWaitForWindowExposed(&topLevel)); QVERIFY(QTest::qWaitForWindowExposed(&topLevel));
QComboBox *testWidget = topLevel.comboBox(); QComboBox *testWidget = topLevel.comboBox();
testWidget->clear(); testWidget->clear();
#if QT_DEPRECATED_SINCE(5, 13)
testWidget->setAutoCompletion(true); testWidget->setAutoCompletion(true);
#endif
testWidget->addItem("Foo"); testWidget->addItem("Foo");
testWidget->addItem("Bar"); testWidget->addItem("Bar");
testWidget->addItem("Boat"); testWidget->addItem("Boat");
@ -837,7 +852,9 @@ void tst_QComboBox::autoCompletionCaseSensitivity()
QCOMPARE(qApp->focusWidget(), (QWidget *)testWidget); QCOMPARE(qApp->focusWidget(), (QWidget *)testWidget);
testWidget->clear(); testWidget->clear();
#if QT_DEPRECATED_SINCE(5, 13)
testWidget->setAutoCompletion(true); testWidget->setAutoCompletion(true);
#endif
testWidget->addItem("Cow"); testWidget->addItem("Cow");
testWidget->addItem("irrelevant1"); testWidget->addItem("irrelevant1");
testWidget->addItem("aww"); testWidget->addItem("aww");
@ -3054,7 +3071,9 @@ void tst_QComboBox::task_QTBUG_31146_popupCompletion()
{ {
QComboBox comboBox; QComboBox comboBox;
comboBox.setEditable(true); comboBox.setEditable(true);
#if QT_DEPRECATED_SINCE(5, 13)
comboBox.setAutoCompletion(true); comboBox.setAutoCompletion(true);
#endif
comboBox.setInsertPolicy(QComboBox::NoInsert); comboBox.setInsertPolicy(QComboBox::NoInsert);
comboBox.completer()->setCaseSensitivity(Qt::CaseInsensitive); comboBox.completer()->setCaseSensitivity(Qt::CaseInsensitive);
comboBox.completer()->setCompletionMode(QCompleter::PopupCompletion); comboBox.completer()->setCompletionMode(QCompleter::PopupCompletion);

View File

@ -461,7 +461,7 @@ void tst_QLabel::unicodeText()
QVBoxLayout *layout = new QVBoxLayout(); QVBoxLayout *layout = new QVBoxLayout();
QLabel *label = new QLabel(text, &frame); QLabel *label = new QLabel(text, &frame);
layout->addWidget(label); layout->addWidget(label);
layout->setMargin(8); layout->setContentsMargins(8, 8, 8, 8);
frame.setLayout(layout); frame.setLayout(layout);
frame.show(); frame.show();
QVERIFY(QTest::qWaitForWindowExposed(&frame)); QVERIFY(QTest::qWaitForWindowExposed(&frame));

View File

@ -880,7 +880,7 @@ void tst_QMdiArea::minimumSizeHint()
{ {
QMdiArea workspace; QMdiArea workspace;
workspace.show(); workspace.show();
QSize expectedSize(workspace.style()->pixelMetric(QStyle::PM_MDIMinimizedWidth), QSize expectedSize(workspace.style()->pixelMetric(QStyle::PM_MdiSubWindowMinimizedWidth),
workspace.style()->pixelMetric(QStyle::PM_TitleBarHeight)); workspace.style()->pixelMetric(QStyle::PM_TitleBarHeight));
qApp->processEvents(); qApp->processEvents();
QAbstractScrollArea dummyScrollArea; QAbstractScrollArea dummyScrollArea;

View File

@ -613,7 +613,7 @@ void tst_QMdiSubWindow::showShaded()
// Calculate mouse position for bottom right corner and simulate a // Calculate mouse position for bottom right corner and simulate a
// vertical resize with the mouse. // 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)); QPoint mousePosition(window->width() - qMax(offset, 2), window->height() - qMax(offset, 2));
QWidget *mouseReceiver = nullptr; QWidget *mouseReceiver = nullptr;
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
@ -759,7 +759,7 @@ void tst_QMdiSubWindow::setOpaqueResizeAndMove()
QTRY_COMPARE(priv->resizeTimerId, -1); QTRY_COMPARE(priv->resizeTimerId, -1);
// Enter resize mode. // 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)); QPoint mousePosition(mouseReceiver->width() - qMax(offset, 2), mouseReceiver->height() - qMax(offset, 2));
sendMouseMove(mouseReceiver, mousePosition, Qt::NoButton); sendMouseMove(mouseReceiver, mousePosition, Qt::NoButton);
sendMousePress(mouseReceiver, mousePosition); sendMousePress(mouseReceiver, mousePosition);
@ -1762,7 +1762,8 @@ void tst_QMdiSubWindow::fixedMinMaxSize()
int minimizedHeight = subWindow->style()->pixelMetric(QStyle::PM_TitleBarHeight, &options); int minimizedHeight = subWindow->style()->pixelMetric(QStyle::PM_TitleBarHeight, &options);
if (!subWindow->style()->styleHint(QStyle::SH_TitleBar_NoBorder, &options, subWindow)) if (!subWindow->style()->styleHint(QStyle::SH_TitleBar_NoBorder, &options, subWindow))
minimizedHeight += 8; 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); const QSize minimizedSize = QSize(minimizedWidth, minimizedHeight);
// Even though the sub window has a minimum size set, it should be possible // Even though the sub window has a minimum size set, it should be possible

View File

@ -599,7 +599,7 @@ void tst_QSplitter::testShowHide()
QWidget widget(&topLevel); QWidget widget(&topLevel);
widget.resize(400 + split->handleWidth(), 200); widget.resize(400 + split->handleWidth(), 200);
QVBoxLayout *lay=new QVBoxLayout(&widget); QVBoxLayout *lay=new QVBoxLayout(&widget);
lay->setMargin(0); lay->setContentsMargins(0, 0, 0, 0);
lay->setSpacing(0); lay->setSpacing(0);
split->addWidget(new QWidget); split->addWidget(new QWidget);
split->addWidget(new QWidget); split->addWidget(new QWidget);

View File

@ -620,7 +620,7 @@ void tst_QTabWidget::heightForWidth()
QWidget *window = new QWidget; QWidget *window = new QWidget;
QVBoxLayout *lay = new QVBoxLayout(window); QVBoxLayout *lay = new QVBoxLayout(window);
lay->setMargin(0); lay->setContentsMargins(0, 0, 0, 0);
lay->setSpacing(0); lay->setSpacing(0);
QTabWidget *tabWid = new QTabWidget(window); QTabWidget *tabWid = new QTabWidget(window);
QWidget *w = new QWidget; QWidget *w = new QWidget;
@ -637,7 +637,7 @@ void tst_QTabWidget::heightForWidth()
); );
label->setWordWrap(true); label->setWordWrap(true);
lay2->addWidget(label); lay2->addWidget(label);
lay2->setMargin(0); lay2->setContentsMargins(0, 0, 0, 0);
lay->addWidget(tabWid); lay->addWidget(tabWid);
int h = window->heightForWidth(160); int h = window->heightForWidth(160);

View File

@ -38,7 +38,7 @@ Chip::Chip(const QColor &color, int x, int y)
setZValue((x + y) % 2); setZValue((x + y) % 2);
setFlags(ItemIsSelectable | ItemIsMovable); setFlags(ItemIsSelectable | ItemIsMovable);
setAcceptsHoverEvents(true); setAcceptHoverEvents(true);
} }
QRectF Chip::boundingRect() const QRectF Chip::boundingRect() const