README-qt6-deprecated-api-fixes.md 3.52 KB
Newer Older
1
Warn against deprecated API in Qt6
Lucie Gerard's avatar
Lucie Gerard committed
2
3

The code is fixed when possible.
4

Maksim Demyanov's avatar
Maksim Demyanov committed
5
* `QDate::toString(Qt::DateFormat format, QCalendar cal)` becomes  `QDate::toString(Qt::DateFormat format)`.
Lucie Gerard's avatar
Lucie Gerard committed
6

Maksim Demyanov's avatar
Maksim Demyanov committed
7
* `QDateTime(const QDate &)` becomes `QDate::startOfDay()`.
Lucie Gerard's avatar
Lucie Gerard committed
8

Maksim Demyanov's avatar
Maksim Demyanov committed
9
* `QDir dir; dir = "..."` becomes	`QDir dir; dir.setPath("...")`.
Lucie Gerard's avatar
Lucie Gerard committed
10

Maksim Demyanov's avatar
Maksim Demyanov committed
11
* `QDir::addResourceSearchPath()` becomes `QDir::addSearchPath()` with prefix.
Lucie Gerard's avatar
Lucie Gerard committed
12

Maksim Demyanov's avatar
Maksim Demyanov committed
13
* Only warning are emitted for `addResourceSearchPath`.
Lucie Gerard's avatar
Lucie Gerard committed
14

Maksim Demyanov's avatar
Maksim Demyanov committed
15
* `QProcess::start()` becomes `QProcess::startCommand()`.
Lucie Gerard's avatar
Lucie Gerard committed
16

Maksim Demyanov's avatar
Maksim Demyanov committed
17
* `QResource::isCompressed()` is replaced with `QResource::compressionAlgorithm()`.
Lucie Gerard's avatar
Lucie Gerard committed
18

Maksim Demyanov's avatar
Maksim Demyanov committed
19
* `QSignalMapper::mapped()` is replaced with `QSignalMapper::mappedInt`, `QSignalMapper::mappedString`, `QSignalMapper::mappedObject` depending on the argument of the function.
Lucie Gerard's avatar
Lucie Gerard committed
20

Maksim Demyanov's avatar
Maksim Demyanov committed
21
* `QString::SplitBehavior` is replaced with `Qt::SplitBehavior`.
Lucie Gerard's avatar
Lucie Gerard committed
22

Maksim Demyanov's avatar
Maksim Demyanov committed
23
* `Qt::MatchRegExp` is replaced with `Qt::MatchRegularExpression`.
Lucie Gerard's avatar
Lucie Gerard committed
24

Maksim Demyanov's avatar
Maksim Demyanov committed
25
* `QTextStream` functions are replaced by the one under the Qt namespace.
26

Maksim Demyanov's avatar
Maksim Demyanov committed
27
* `QVariant` operators '`<`' '`<=`' '`>`' '`>=`' are replaced with `QVariant::compare()` function.
28

Maksim Demyanov's avatar
Maksim Demyanov committed
29
30
31
32
33
34
35
* `QVariant v1; QVariant v2; 'v1 < v2'` becomes '`QVariant::compare(v1, v2) < 0`'.

* `QWizard::visitedPages()` is replaced with `QWizard::visitedIds()`.

* `QButtonGroup buttonClicked/Pressed/Released/Toggled(int)` is replaced with `QButtonGroup::idClicked/Pressed/Released/Toggled(int)`.

* `QCombobox::activated(const QString &)` and `highlighted(const QString &)` are replaced with `QComboBox::textActivated` or `textHighlighted` respectively.
Lucie Gerard's avatar
Lucie Gerard committed
36

37
Warning for:  
Maksim Demyanov's avatar
Maksim Demyanov committed
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69

* Usage of `QMap::insertMulti`, `uniqueKeys`, `values`, `unite`, to be replaced with QMultiMap versions.  

* Usage of `QHash::uniqueKeys`, to be replaced with `QMultiHash` versions.  

* Usage of `LinkedList`, to be replaced with `std::list`.  

* Usage of global `qrand()` and `qsrand()`, to be replaced using `QRandomGenerator`.  

* Usage of `QTimeLine::curveShape` and `QTimeLine::setCurveShape`, to be replaced using `QTimeLine::easingCurve` and `QTimeLine::setEasingCurve`.  

* Usage of `QSet` and `QHash` biderectional iterator. Code has to be ported using forward iterator.  

* Usage of `QMacCocoaViewContainer`, to be replaced using `QWindow::fromWinId` and `QWidget::createWindowContainer` instead.  

* Usage of `QMacNativeWidget`, to be replaced using `QWidget::winId` instead.  

* Usage of `QComboBox::SizeAdjustPolicy::AdjustToMinimumContentsLength`, to be replaced using `AdjustToContents` or `AdjustToContentsOnFirstShow`.  

* Usage of `QComboBox::currentIndexChanged(const QString &)`, to be replaced using `currentIndexChanged(int)` instead, and getting the text using `itemText(index)`.  

* Usage of `QSplashScreen(QWidget *parent,...)`, to be replaced with the constructor taking a `QScreen *`.  

* Usage of `QTextBrowser::highlighted(const QString &)`, to be replaced with `highlighted(const QUrl &)`.  

* Usage of `QDockWidget::AllDockWidgetFeatures`, to  be replaced with  `DockWidgetClosable|DockWidgetMovable|DockWidgetFloatable`.  

* Usage of `QDirModel`, to be replaced with `QFileSystemModel`.  

* Usage of `QGraphicsView::matrix`, `setMatrix(const QMatrix &)` and `resetMatrix`, to be replaced with `QGraphicsView::transform`, `setTransform(const QTransform &)` and `resetTransfrom`.  

* Usage of the following QStyle enum: `QStyle::PixelMetrix::PM_DefaultTopLevelMargin`, `PM_DefaultChildMargin`, `PM_DefaultLayoutSpacing` and `QStyle::SubElement::SE_DialogButtonBoxLayoutItem`.  
70
71

This fix-it is intended to aid the user porting from Qt5 to Qt6.  
72
Run this check with Qt5. The produced fixed code will compile on Qt6.