Remove deprecated members from QtWidgets/widgets classes

Cleaning up those that are trivial to remove because they have direct
replacements.

The QLabel changes to the pixmap/picture getters provide the following
migration path:

QPixmap *ppix = l->pixmap(); // up to 5.15, warns in 5.15
QPixmap pval = l->pixmap(Qt::ReturnByValue); // new in 5.15, works in 6
QPixmap pixmap = l->pixmap(); // from Qt 6 on

The overload with argument can be deprecated after the first LTS or
so.

Change-Id: I8494ceeea55b2aeda0bd340640ad95cb7c91f7d6
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
bb10
Volker Hilsheimer 2020-04-16 15:00:06 +02:00
parent 30141b2fb7
commit 714409b23c
17 changed files with 43 additions and 269 deletions

View File

@ -1240,11 +1240,6 @@ void QDockWidgetPrivate::setWindowState(bool floating, bool unplug, const QRect
bar on its left side. This can be used to
increase the amount of vertical space in
a QMainWindow.
\value AllDockWidgetFeatures (Deprecated) The dock widget can be closed, moved,
and floated. Since new features might be added in future
releases, the look and behavior of dock widgets might
change if you use this flag. Please specify individual
flags instead.
\value NoDockWidgetFeatures The dock widget cannot be closed, moved,
or floated.

View File

@ -78,10 +78,6 @@ public:
DockWidgetVerticalTitleBar = 0x08,
DockWidgetFeatureMask = 0x0f,
#if QT_DEPRECATED_SINCE(5, 15)
AllDockWidgetFeatures Q_DECL_ENUMERATOR_DEPRECATED =
DockWidgetClosable|DockWidgetMovable|DockWidgetFloatable, // ### Qt 6: remove
#endif
NoDockWidgetFeatures = 0x00,
Reserved = 0xff

View File

@ -186,54 +186,30 @@ QLabelPrivate::~QLabelPrivate()
{fowler}{GUI Design Handbook: Label}
*/
#ifndef QT_NO_PICTURE
#if QT_DEPRECATED_SINCE(5, 15)
/*!
\deprecated
New code should use the other overload which returns QPicture by-value.
This function returns the label's picture or \c nullptr if the label doesn't have a
picture.
*/
const QPicture *QLabel::picture() const
{
Q_D(const QLabel);
return d->picture;
}
#endif // QT_DEPRECATED_SINCE(5, 15)
/*!
\fn QPicture QLabel::picture(Qt::ReturnByValueConstant) const
\obsolete Use the overload without argument instead.
\since 5.15
Returns the label's picture.
Previously, Qt provided a version of \c picture() which returned the picture
by-pointer. That version is now deprecated. To maintain compatibility
with old code, you can explicitly differentiate between the by-pointer
function and the by-value function:
\code
const QPicture *picPtr = label->picture();
QPicture picVal = label->picture(Qt::ReturnByValue);
\endcode
If you disable the deprecated version using the QT_DISABLE_DEPRECATED_BEFORE
macro, then you can omit \c Qt::ReturnByValue as shown below:
\code
QPicture picVal = label->picture();
\endcode
by-pointer. That version is now removed. This overload allowed to
explicitly differentiate between the by-pointer function and the by-value.
*/
QPicture QLabel::picture(Qt::ReturnByValueConstant) const
/*!
\since 6.0
Returns the label's picture.
*/
QPicture QLabel::picture() const
{
Q_D(const QLabel);
if (d->picture)
return *(d->picture);
return QPicture();
}
#endif
/*!
@ -389,26 +365,6 @@ void QLabel::clear()
\property QLabel::pixmap
\brief the label's pixmap.
Previously, Qt provided a version of \c pixmap() which returned the pixmap
by-pointer. That version is now deprecated. To maintain compatibility
with old code, you can explicitly differentiate between the by-pointer
function and the by-value function:
\code
const QPixmap *pixmapPtr = label->pixmap();
QPixmap pixmapVal = label->pixmap(Qt::ReturnByValue);
\endcode
If you disable the deprecated version using the QT_DISABLE_DEPRECATED_BEFORE
macro, then you can omit \c Qt::ReturnByValue as shown below:
\code
QPixmap pixmapVal = label->pixmap();
\endcode
If no pixmap has been set, the deprecated getter function will return
\c nullptr.
Setting the pixmap clears any previous content. The buddy
shortcut, if any, is disabled.
*/
@ -426,23 +382,7 @@ void QLabel::setPixmap(const QPixmap &pixmap)
d->updateLabel();
}
#if QT_DEPRECATED_SINCE(5, 15)
/*!
\deprecated
New code should use the other overload which returns QPixmap by-value.
*/
const QPixmap *QLabel::pixmap() const
{
Q_D(const QLabel);
return d->pixmap;
}
#endif // QT_DEPRECATED_SINCE(5, 15)
/*!
\since 5.15
*/
QPixmap QLabel::pixmap(Qt::ReturnByValueConstant) const
QPixmap QLabel::pixmap() const
{
Q_D(const QLabel);
if (d->pixmap)
@ -450,6 +390,23 @@ QPixmap QLabel::pixmap(Qt::ReturnByValueConstant) const
return QPixmap();
}
/*!
\fn QPixmap QLabel::pixmap(Qt::ReturnByValueConstant) const
\obsolete Use the overload without argument instead.
\since 5.15
Returns the label's pixmap.
Previously, Qt provided a version of \c pixmap() which returned the pixmap
by-pointer. That version has now been removed. This overload allowed to
explicitly differentiate between the by-pointer function and the by-value.
\code
QPixmap pixmapVal = label->pixmap(Qt::ReturnByValue);
\endcode
*/
#ifndef QT_NO_PICTURE
/*!
Sets the label contents to \a picture. Any previous content is

View File

@ -42,6 +42,7 @@
#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qframe.h>
#include <QtGui/qpicture.h>
QT_REQUIRE_CONFIG(label);
@ -73,24 +74,16 @@ public:
QString text() const;
#if QT_DEPRECATED_SINCE(5,15)
QT_DEPRECATED_VERSION_X(5, 15, "Use the other overload which returns QPixmap by-value")
const QPixmap *pixmap() const; // ### Qt 7: Remove function
QPixmap pixmap(Qt::ReturnByValueConstant) const;
#else
QPixmap pixmap(Qt::ReturnByValueConstant = Qt::ReturnByValue) const; // ### Qt 7: Remove arg
#endif // QT_DEPRECATED_SINCE(5,15)
#if QT_DEPRECATED_SINCE(6,6)
QPixmap pixmap(Qt::ReturnByValueConstant) const { return pixmap(); }
#endif
QPixmap pixmap() const;
#ifndef QT_NO_PICTURE
# if QT_DEPRECATED_SINCE(5,15)
QT_DEPRECATED_VERSION_X(5, 15, "Use the other overload which returns QPicture by-value")
const QPicture *picture() const; // ### Qt 7: Remove function
QPicture picture(Qt::ReturnByValueConstant) const;
# else
QPicture picture(Qt::ReturnByValueConstant = Qt::ReturnByValue) const; // ### Qt 7: Remove arg
# endif // QT_DEPRECATED_SINCE(5,15)
#if QT_DEPRECATED_SINCE(6,6)
QPicture picture(Qt::ReturnByValueConstant) const { return picture(); }
#endif
QPicture picture() const;
#endif
#if QT_CONFIG(movie)
QMovie *movie() const;

View File

@ -1158,30 +1158,6 @@ void QLineEdit::setTextMargins(const QMargins &margins)
update();
}
#if QT_DEPRECATED_SINCE(5, 14)
/*!
\obsolete
Use textMargins()
Returns the widget's text margins for \a left, \a top, \a right, and \a bottom.
\since 4.5
\sa setTextMargins()
*/
void QLineEdit::getTextMargins(int *left, int *top, int *right, int *bottom) const
{
QMargins m = textMargins();
if (left)
*left = m.left();
if (top)
*top = m.top();
if (right)
*right = m.right();
if (bottom)
*bottom = m.bottom();
}
#endif
/*!
\since 4.6
Returns the widget's text margins.

View File

@ -172,10 +172,6 @@ public:
void setTextMargins(int left, int top, int right, int bottom);
void setTextMargins(const QMargins &margins);
#if QT_DEPRECATED_SINCE(5, 14)
QT_DEPRECATED_X("use textMargins()")
void getTextMargins(int *left, int *top, int *right, int *bottom) const;
#endif
QMargins textMargins() const;
#if QT_CONFIG(action)

View File

@ -288,11 +288,6 @@ private:
friend void qt_mac_menu_emit_hovered(QMenu *menu, QAction *action);
};
#ifdef Q_OS_MACOS
// ### Qt 4 compatibility; remove in Qt 6
inline QT_DEPRECATED void qt_mac_set_dock_menu(QMenu *menu) { menu->setAsDockMenu(); }
#endif
QT_END_NAMESPACE
#endif // QMENU_H

View File

@ -2491,26 +2491,6 @@ void QPlainTextEdit::setOverwriteMode(bool overwrite)
d->control->setOverwriteMode(overwrite);
}
#if QT_DEPRECATED_SINCE(5, 10)
/*!
\property QPlainTextEdit::tabStopWidth
\brief the tab stop width in pixels
\deprecated in Qt 5.10. Use tabStopDistance instead.
By default, this property contains a value of 80.
*/
int QPlainTextEdit::tabStopWidth() const
{
return qRound(tabStopDistance());
}
void QPlainTextEdit::setTabStopWidth(int width)
{
setTabStopDistance(width);
}
#endif
/*!
\property QPlainTextEdit::tabStopDistance
\brief the tab stop distance in pixels

View File

@ -74,9 +74,6 @@ class Q_WIDGETS_EXPORT QPlainTextEdit : public QAbstractScrollArea
Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly)
Q_PROPERTY(QString plainText READ toPlainText WRITE setPlainText NOTIFY textChanged USER true)
Q_PROPERTY(bool overwriteMode READ overwriteMode WRITE setOverwriteMode)
#if QT_DEPRECATED_SINCE(5, 10)
Q_PROPERTY(int tabStopWidth READ tabStopWidth WRITE setTabStopWidth)
#endif
Q_PROPERTY(qreal tabStopDistance READ tabStopDistance WRITE setTabStopDistance)
Q_PROPERTY(int cursorWidth READ cursorWidth WRITE setCursorWidth)
Q_PROPERTY(Qt::TextInteractionFlags textInteractionFlags READ textInteractionFlags WRITE setTextInteractionFlags)
@ -171,11 +168,6 @@ public:
bool overwriteMode() const;
void setOverwriteMode(bool overwrite);
#if QT_DEPRECATED_SINCE(5, 10)
QT_DEPRECATED int tabStopWidth() const;
QT_DEPRECATED void setTabStopWidth(int width);
#endif
qreal tabStopDistance() const;
void setTabStopDistance(qreal distance);

View File

@ -157,25 +157,6 @@ QSplashScreen::QSplashScreen(QScreen *screen, const QPixmap &pixmap, Qt::WindowF
d_func()->setPixmap(pixmap, screen);
}
#if QT_DEPRECATED_SINCE(5, 15)
/*!
\overload
\obsolete
This function allows you to specify a parent for your splashscreen. The
typical use for this constructor is if you have a multiple screens and
prefer to have the splash screen on a different screen than your primary
one. In that case pass the proper desktop() as the \a parent.
*/
QSplashScreen::QSplashScreen(QWidget *parent, const QPixmap &pixmap, Qt::WindowFlags f)
: QWidget(*new QSplashScreenPrivate, parent, Qt::SplashScreen | Qt::FramelessWindowHint | f)
{
// Does an implicit repaint. Explicitly pass parent as QObject::parent()
// is still 0 here due to QWidget's special handling.
d_func()->setPixmap(pixmap, QSplashScreenPrivate::screenFor(parent));
}
#endif
/*!
Destructor.
*/

View File

@ -56,10 +56,6 @@ class Q_WIDGETS_EXPORT QSplashScreen : public QWidget
public:
explicit QSplashScreen(const QPixmap &pixmap = QPixmap(), Qt::WindowFlags f = Qt::WindowFlags());
QSplashScreen(QScreen *screen, const QPixmap &pixmap = QPixmap(), Qt::WindowFlags f = Qt::WindowFlags());
#if QT_DEPRECATED_SINCE(5, 15)
QT_DEPRECATED_VERSION_X_5_15("Use the constructor taking a QScreen *")
QSplashScreen(QWidget *parent, const QPixmap &pixmap = QPixmap(), Qt::WindowFlags f = Qt::WindowFlags());
#endif
virtual ~QSplashScreen();
void setPixmap(const QPixmap &pixmap);

View File

@ -1780,40 +1780,6 @@ void QSplitter::setStretchFactor(int index, int stretch)
widget->setSizePolicy(sp);
}
#if QT_DEPRECATED_SINCE(5, 13)
/*!
\relates QSplitter
\obsolete
Use \a ts << \a{splitter}.saveState() instead.
*/
QTextStream& operator<<(QTextStream& ts, const QSplitter& splitter)
{
ts << splitter.saveState() << Qt::endl;
return ts;
}
/*!
\relates QSplitter
\obsolete
Use \a ts >> \a{splitter}.restoreState() instead.
*/
QTextStream& operator>>(QTextStream& ts, QSplitter& splitter)
{
QString line = ts.readLine();
line = line.simplified();
line.replace(QLatin1Char(' '), QString());
line = std::move(line).toUpper();
splitter.restoreState(std::move(line).toLatin1());
return ts;
}
#endif
QT_END_NAMESPACE
#include "moc_qsplitter.cpp"

View File

@ -128,12 +128,6 @@ private:
friend class QSplitterHandle;
};
#if QT_DEPRECATED_SINCE(5, 13)
QT_DEPRECATED_X("Use QSplitter::saveState() instead")
Q_WIDGETS_EXPORT QTextStream& operator<<(QTextStream&, const QSplitter&);
QT_DEPRECATED_X("Use QSplitter::restoreState() instead")
Q_WIDGETS_EXPORT QTextStream& operator>>(QTextStream&, QSplitter&);
#endif
class QSplitterHandlePrivate;
class Q_WIDGETS_EXPORT QSplitterHandle : public QWidget

View File

@ -2053,27 +2053,6 @@ void QTextEdit::setOverwriteMode(bool overwrite)
d->control->setOverwriteMode(overwrite);
}
#if QT_DEPRECATED_SINCE(5, 10)
/*!
\property QTextEdit::tabStopWidth
\brief the tab stop width in pixels
\since 4.1
\deprecated in Qt 5.10. Use tabStopDistance instead.
By default, this property contains a value of 80 pixels.
*/
int QTextEdit::tabStopWidth() const
{
return qRound(tabStopDistance());
}
void QTextEdit::setTabStopWidth(int width)
{
setTabStopDistance(width);
}
#endif
/*!
\property QTextEdit::tabStopDistance
\brief the tab stop distance in pixels

View File

@ -79,9 +79,6 @@ class Q_WIDGETS_EXPORT QTextEdit : public QAbstractScrollArea
#endif
Q_PROPERTY(QString plainText READ toPlainText WRITE setPlainText DESIGNABLE false)
Q_PROPERTY(bool overwriteMode READ overwriteMode WRITE setOverwriteMode)
#if QT_DEPRECATED_SINCE(5, 10)
Q_PROPERTY(int tabStopWidth READ tabStopWidth WRITE setTabStopWidth)
#endif
Q_PROPERTY(qreal tabStopDistance READ tabStopDistance WRITE setTabStopDistance)
Q_PROPERTY(bool acceptRichText READ acceptRichText WRITE setAcceptRichText)
Q_PROPERTY(int cursorWidth READ cursorWidth WRITE setCursorWidth)
@ -195,11 +192,6 @@ public:
bool overwriteMode() const;
void setOverwriteMode(bool overwrite);
#if QT_DEPRECATED_SINCE(5, 10)
QT_DEPRECATED int tabStopWidth() const;
QT_DEPRECATED void setTabStopWidth(int width);
#endif
qreal tabStopDistance() const;
void setTabStopDistance(qreal distance);

View File

@ -103,8 +103,6 @@ void tst_QDockWidget::getSetCheck()
QCOMPARE(QDockWidget::DockWidgetFeatures(QDockWidget::DockWidgetMovable), obj1.features());
obj1.setFeatures(QDockWidget::DockWidgetFeatures(QDockWidget::DockWidgetFloatable));
QCOMPARE(QDockWidget::DockWidgetFeatures(QDockWidget::DockWidgetFloatable), obj1.features());
obj1.setFeatures(QDockWidget::DockWidgetFeatures(QDockWidget::AllDockWidgetFeatures));
QCOMPARE(QDockWidget::DockWidgetFeatures(QDockWidget::AllDockWidgetFeatures), obj1.features());
obj1.setFeatures(QDockWidget::DockWidgetFeatures(QDockWidget::NoDockWidgetFeatures));
QCOMPARE(QDockWidget::DockWidgetFeatures(QDockWidget::NoDockWidgetFeatures), obj1.features());
}
@ -207,9 +205,9 @@ void tst_QDockWidget::features()
QSignalSpy spy(&dw, SIGNAL(featuresChanged(QDockWidget::DockWidgetFeatures)));
// default features for dock widgets
int allDockWidgetFeatures = QDockWidget::DockWidgetClosable |
QDockWidget::DockWidgetMovable |
QDockWidget::DockWidgetFloatable;
const auto allDockWidgetFeatures = QDockWidget::DockWidgetClosable |
QDockWidget::DockWidgetMovable |
QDockWidget::DockWidgetFloatable;
// defaults
QCOMPARE(dw.features(), allDockWidgetFeatures);
@ -323,8 +321,8 @@ void tst_QDockWidget::features()
QCOMPARE(spy.count(), 0);
spy.clear();
dw.setFeatures(QDockWidget::AllDockWidgetFeatures);
QCOMPARE(dw.features(), QDockWidget::AllDockWidgetFeatures);
dw.setFeatures(allDockWidgetFeatures);
QCOMPARE(dw.features(), allDockWidgetFeatures);
QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetClosable));
QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetMovable));
QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetFloatable));

View File

@ -3582,18 +3582,6 @@ void tst_QLineEdit::textMargin()
QCOMPARE(right, margins.right());
QCOMPARE(bottom, margins.bottom());
#if QT_DEPRECATED_SINCE(5, 14)
int l;
int t;
int r;
int b;
testWidget.getTextMargins(&l, &t, &r, &b);
QCOMPARE(left, l);
QCOMPARE(top, t);
QCOMPARE(right, r);
QCOMPARE(bottom, b);
#endif
QTest::mouseClick(&testWidget, Qt::LeftButton, {}, mousePressPos);
QTRY_COMPARE(testWidget.cursorPosition(), cursorPosition);
}