Multiple warning messages when using split() in Qt 5.15.2
-
Hello All,
How to supress the warnings when QString::split() API is used. Please find the sample code below
QString str = "10:20";
QStringList liststr = str.split(':', QString::SkipEmptyParts);
int value1 = liststr.at(1).toUInt();
int value2 = liststr.at(0).toUInt();The warnings are:
'split' is deprecated: Use Qt::SplitBehavior variant instead
qstring.h:609:23: note: 'split' has been explicitly marked deprecated here
qglobal.h:374:45: note: expanded from macro 'QT_DEPRECATED_VERSION_X_5_15'
qglobal.h:294:33: note: expanded from macro 'QT_DEPRECATED_X'
qcompilerdetection.h:675:55: note: expanded from macro 'Q_DECL_DEPRECATED_X'How to resolve this ??
-
Yeah, I just looked at the doc...usually when Qt deprecates something, it suggests an alternative, but evidently not in this case. You may have to copy an online example, and do it yourself. This example looks reasonable. Good luck.
-
The warning sugests you use Qt::SkipEmptyParts:
QStringList liststr = str.split(':', Qt::SkipEmptyParts);
This should work from Qt 5.14 onwards.
If you (for whatever reason) just want to silence the warning, set https://doc.qt.io/qt-5/qtglobal.html#QT_DISABLE_DEPRECATED_BEFORE to an older version ...
-
The warning sugests you use Qt::SkipEmptyParts:
QStringList liststr = str.split(':', Qt::SkipEmptyParts);
This should work from Qt 5.14 onwards.
If you (for whatever reason) just want to silence the warning, set https://doc.qt.io/qt-5/qtglobal.html#QT_DISABLE_DEPRECATED_BEFORE to an older version ...