qtqt5

error: ‘SkipEmptyParts’ is not a member of ‘Qt’


I am randomly encountering this error without updating the code using qt5:

error: ‘SkipEmptyParts’ is not a member of ‘Qt’


Solution

  • I solved replacing Qt::SkipEmptyParts with QString::SkipEmptyParts because Qt::SkipEmptyParts has been deprecated.

    If you would like to keep the back-compatibility but also use the new version for qt versions >= 5.11.x you could use:

    #if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
      const auto skip_empty_parts = Qt::SkipEmptyParts;
    #else
      const auto skip_empty_parts = QString::SkipEmptyParts;
    #endif
    

    UPDATED: as @Alienpenguin said, QString::SkipEmptyParts has been deprecated and removed in Qt6, it is possible to use Qt::SkipEmptyParts since Qt 5.14.