Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Multiple warning messages when using split() in Qt 5.15.2

Multiple warning messages when using split() in Qt 5.15.2

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 3 Posters 4.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Praveen.Illa
    wrote on last edited by
    #1

    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 ??

    1 Reply Last reply
    1
    • mzimmersM Offline
      mzimmersM Offline
      mzimmers
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • kkoehneK Offline
        kkoehneK Offline
        kkoehne
        Moderators
        wrote on last edited by
        #3

        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 ...

        Director R&D, The Qt Company

        mzimmersM 1 Reply Last reply
        4
        • kkoehneK kkoehne

          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 ...

          mzimmersM Offline
          mzimmersM Offline
          mzimmers
          wrote on last edited by
          #4

          @kkoehne ah, after reading your reply, the error message makes (a little) more sense.

          That's not a great error message though...both it and the docs section talking about the deprecation could use some rewording, IMO.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved