From 714409b23ce5ec33e56adce5ba1966aad67c3b34 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Thu, 16 Apr 2020 15:00:06 +0200 Subject: 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 Reviewed-by: Shawn Rutledge --- src/widgets/widgets/qdockwidget.cpp | 5 -- src/widgets/widgets/qdockwidget.h | 4 -- src/widgets/widgets/qlabel.cpp | 97 ++++++++++------------------------ src/widgets/widgets/qlabel.h | 25 ++++----- src/widgets/widgets/qlineedit.cpp | 24 --------- src/widgets/widgets/qlineedit.h | 4 -- src/widgets/widgets/qmenu.h | 5 -- src/widgets/widgets/qplaintextedit.cpp | 20 ------- src/widgets/widgets/qplaintextedit.h | 8 --- src/widgets/widgets/qsplashscreen.cpp | 19 ------- src/widgets/widgets/qsplashscreen.h | 4 -- src/widgets/widgets/qsplitter.cpp | 34 ------------ src/widgets/widgets/qsplitter.h | 6 --- src/widgets/widgets/qtextedit.cpp | 21 -------- src/widgets/widgets/qtextedit.h | 8 --- 15 files changed, 36 insertions(+), 248 deletions(-) (limited to 'src/widgets/widgets') diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp index cfe17af6e9..102f370488 100644 --- a/src/widgets/widgets/qdockwidget.cpp +++ b/src/widgets/widgets/qdockwidget.cpp @@ -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. diff --git a/src/widgets/widgets/qdockwidget.h b/src/widgets/widgets/qdockwidget.h index 36dff4d420..d553407fb5 100644 --- a/src/widgets/widgets/qdockwidget.h +++ b/src/widgets/widgets/qdockwidget.h @@ -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 diff --git a/src/widgets/widgets/qlabel.cpp b/src/widgets/widgets/qlabel.cpp index a0b5bdd39f..f373ecfab4 100644 --- a/src/widgets/widgets/qlabel.cpp +++ b/src/widgets/widgets/qlabel.cpp @@ -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 + by-pointer. That version is now removed. This overload allowed to + explicitly differentiate between the by-pointer function and the by-value. +*/ - If you disable the deprecated version using the QT_DISABLE_DEPRECATED_BEFORE - macro, then you can omit \c Qt::ReturnByValue as shown below: +/*! + \since 6.0 - \code - QPicture picVal = label->picture(); - \endcode + Returns the label's picture. */ - -QPicture QLabel::picture(Qt::ReturnByValueConstant) const +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,29 +382,30 @@ 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 +QPixmap QLabel::pixmap() const { Q_D(const QLabel); - return d->pixmap; + if (d->pixmap) + return *(d->pixmap); + return QPixmap(); } -#endif // QT_DEPRECATED_SINCE(5, 15) /*! + \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 */ -QPixmap QLabel::pixmap(Qt::ReturnByValueConstant) const -{ - Q_D(const QLabel); - if (d->pixmap) - return *(d->pixmap); - return QPixmap(); -} #ifndef QT_NO_PICTURE /*! diff --git a/src/widgets/widgets/qlabel.h b/src/widgets/widgets/qlabel.h index c9552efd8a..8cc86b421e 100644 --- a/src/widgets/widgets/qlabel.h +++ b/src/widgets/widgets/qlabel.h @@ -42,6 +42,7 @@ #include #include +#include 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; diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index 8b8a6b3208..5ec79ce6ea 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -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. diff --git a/src/widgets/widgets/qlineedit.h b/src/widgets/widgets/qlineedit.h index 1cf1f24449..41efab9229 100644 --- a/src/widgets/widgets/qlineedit.h +++ b/src/widgets/widgets/qlineedit.h @@ -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) diff --git a/src/widgets/widgets/qmenu.h b/src/widgets/widgets/qmenu.h index 7a60907532..a163e94c81 100644 --- a/src/widgets/widgets/qmenu.h +++ b/src/widgets/widgets/qmenu.h @@ -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 diff --git a/src/widgets/widgets/qplaintextedit.cpp b/src/widgets/widgets/qplaintextedit.cpp index d62d9ac229..c33b99432a 100644 --- a/src/widgets/widgets/qplaintextedit.cpp +++ b/src/widgets/widgets/qplaintextedit.cpp @@ -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 diff --git a/src/widgets/widgets/qplaintextedit.h b/src/widgets/widgets/qplaintextedit.h index 881bdf7c24..f2213c9ca7 100644 --- a/src/widgets/widgets/qplaintextedit.h +++ b/src/widgets/widgets/qplaintextedit.h @@ -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); diff --git a/src/widgets/widgets/qsplashscreen.cpp b/src/widgets/widgets/qsplashscreen.cpp index 70f05033ea..407f6a0795 100644 --- a/src/widgets/widgets/qsplashscreen.cpp +++ b/src/widgets/widgets/qsplashscreen.cpp @@ -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. */ diff --git a/src/widgets/widgets/qsplashscreen.h b/src/widgets/widgets/qsplashscreen.h index 1877493fcf..de51494f85 100644 --- a/src/widgets/widgets/qsplashscreen.h +++ b/src/widgets/widgets/qsplashscreen.h @@ -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); diff --git a/src/widgets/widgets/qsplitter.cpp b/src/widgets/widgets/qsplitter.cpp index f0ea068edd..b8540176e7 100644 --- a/src/widgets/widgets/qsplitter.cpp +++ b/src/widgets/widgets/qsplitter.cpp @@ -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" diff --git a/src/widgets/widgets/qsplitter.h b/src/widgets/widgets/qsplitter.h index 658914ae39..b7a097ca92 100644 --- a/src/widgets/widgets/qsplitter.h +++ b/src/widgets/widgets/qsplitter.h @@ -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 diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp index b8dec4273d..9a02721e61 100644 --- a/src/widgets/widgets/qtextedit.cpp +++ b/src/widgets/widgets/qtextedit.cpp @@ -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 diff --git a/src/widgets/widgets/qtextedit.h b/src/widgets/widgets/qtextedit.h index 5a50995dd3..91b7d05d9f 100644 --- a/src/widgets/widgets/qtextedit.h +++ b/src/widgets/widgets/qtextedit.h @@ -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); -- cgit v1.2.3