It seems that the wrong code snippet is used for the QString::slice documentation:
See also https://doc.qt.io/qt-6/qstring.html#slice