mCRL2 icon indicating copy to clipboard operation
mCRL2 copied to clipboard

Several Qt deprecation warnings under 5.15

Open tneele opened this issue 4 years ago • 3 comments

When compiling under Qt 5.15, several deprecation warning are issued. Here is a sample:

src/tools/release/ltsview/markmanager.h:61:9: warning: 'QLinkedList<MarkRule>' is deprecated: Use std::list instead [-Wdeprecated-declarations]
typedef QLinkedList<MarkRule>::iterator MarkRuleIndex;
        ^
qt-everywhere-src-5.15.0/qtbase/lib/QtCore.framework/Headers/qlinkedlist.h:92:7: note: 'QLinkedList<MarkRule>' has been explicitly marked deprecated here
class QT_DEPRECATED_VERSION_X_5_15("Use std::list instead") QLinkedList
      ^
src/libraries/gui/include/mcrl2/gui/persistentfiledialog.h:31:161: warning: 'QFlags' is deprecated: Use default constructor instead [-Wdeprecated-declarations]
    QString     getOpenFileName       ( const QString & caption = QString(), const QString & filter = QString(), QString * selectedFilter = 0, QFileDialog::Options options = 0 );
                                                                                                                                                                    ^
qt-everywhere-src-5.15.0/qtbase/lib/QtCore.framework/Headers/qflags.h:123:5: note: 'QFlags' has been explicitly marked deprecated here
    QT_DEPRECATED_X("Use default constructor instead") Q_DECL_CONSTEXPR inline QFlags(Zero) noexcept : i(0) {}
    ^
src/tools/release/diagraphica/examiner.cpp:476:56: warning: 'fromStdVector' is deprecated: Use QVector<T>(vector.begin(), vector.end()) instead. [-Wdeprecated-declarations]
        emit routingCluster(frame, QVector<Cluster *>::fromStdVector(framesHist).toList(), QVector<Attribute *>::fromStdVector(attributes).toList());
                                                       ^
qt-everywhere-src-5.15.0/qtbase/lib/QtCore.framework/Headers/qvector.h:305:5: note: 'fromStdVector' has been explicitly marked deprecated here
    QT_DEPRECATED_X("Use QVector<T>(vector.begin(), vector.end()) instead.")
    ^
src/tools/release/diagraphica/mainwindow.cpp:665:57: warning: 'toStdVector' is deprecated: Use std::vector<T>(vector.begin(), vector.end()) instead. [-Wdeprecated-declarations]
    m_examiner->setFrame(cluster, attributes.toVector().toStdVector(), VisUtils::coolBlue);
                                                        ^
qt-everywhere-src-5.15.0/qtbase/lib/QtCore.framework/Headers/qvector.h:308:5: note: 'toStdVector' has been explicitly marked deprecated here
    QT_DEPRECATED_X("Use std::vector<T>(vector.begin(), vector.end()) instead.")
    ^

tneele avatar May 30 '20 09:05 tneele

I am aware of Qt related deprecated warnings in codeeditor.cpp (not mentioned above). Functions QPlainTextEdit::setTabStopWidth and QFontMetrics::width are deprecated since Qt 5.10. Since we have Qt 5.9 as minimum requirement, these should not be changed yet. I am not sure though whether these deprecated warnings are reason enough to raise the minimum requirement for Qt.

Valo13 avatar Jul 23 '20 14:07 Valo13

We may want to change deprecated messages as long as they are supported by either standard C or Qt 5.9. When keeping Qt5.9 as a lower bound leads to the impossibility to do obvious improvements, we may consider to increase it. But if QPlainTextEdit::setTabStopWidth and QFontMetrics::width can be replaced by constructs supported in Qt5.9 or standard C++ it is worth doing it.

jgroote avatar Jul 23 '20 15:07 jgroote

Building with Qt 5.13, I could find the following Qt related deprecated warnings:

Deprecated since Qt 4.2:

28>C:\Users\bunteo\Documents\mCRL2-git\tools\release\diagraphica\movabletablewidget.cpp(131,1): warning C4996: 'QTableWidget::setItemSelected': Use QTableWidgetItem::setSelected() instead

Deprecated since Qt 5.2:

28>C:\Users\bunteo\Documents\mCRL2-git\tools\release\diagraphica\movabletablewidget.cpp(109,1): warning C4996: 'qSort': Use std::sort

Deprecated since Qt 5.10:

7>C:\Users\bunteo\Documents\mCRL2-git\libraries\gui\source\codeeditor.cpp(253,1): warning C4996: 'QPlainTextEdit::setTabStopWidth': was declared deprecated
7>C:\Users\bunteo\Documents\mCRL2-git\libraries\gui\source\codeeditor.cpp(374,1): warning C4996: 'QFontMetrics::width': Use QFontMetrics::horizontalAdvance

Deprecated since Qt 5.13:

28>C:\Users\bunteo\Documents\mCRL2-git\tools\release\diagraphica\diagram.cpp(88,1): warning C4996: 'QList<Shape *>::swap': Use QList<T>::swapItemsAt()
28>C:\Users\bunteo\Documents\mCRL2-git\tools\release\diagraphica\diagram.cpp(99,1): warning C4996: 'QList<Shape *>::swap': Use QList<T>::swapItemsAt()

The warnings in the first post are deprecated since Qt 5.14 or higher.

I read that they are also planning to make QList deprecated in Qt 6, which is used in some of the older mCRL2 tools that use Qt.

Valo13 avatar Jul 23 '20 15:07 Valo13

I have applied the patches by Ferry (with some adaptations) since the minimum Qt version is now 5.12 after the build servers have been upgraded. If there are more deprecation warnings that I have missed let me know.

mlaveaux avatar May 16 '23 13:05 mlaveaux

I have resolved all deprecation warnings that occurred so far under Qt 5.15.9. There is some code introduced for Qt 5.12 compatibility that should be removed in due time.

mlaveaux avatar Jun 05 '23 11:06 mlaveaux