Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-117705

Incorrect documentation for QStringEncoder and QStringDecoder

    XMLWordPrintable

Details

    • 9e5df4ae5 (dev), bab635fea (6.6), 47eb8b332 (6.5)

    Description

      The documentation QStringDecoder and QStringEncoder incorrectly states that the encoding methods return a QByteArray and the decoding methods return a QString, where they instead return some other undocumented structures. This causes code like the following to fail to compile:

      [](QByteArray const & v) {
         QStringDecoder decoder("UTF-8");
         auto result = decoder(v);
         if (!decoder.hasError())
             return result;
         return QString("huh?");
      }(input);
      

      with errors like:

      main.cpp: In lambda function:
      main.cpp:9:15: error: inconsistent types 'QStringDecoder::EncodedData<const QByteArray&>' and 'QString' deduced for lambda return type
          9 |        return QString("huh?");
            |               ^~~~~~~~~~~~~~~
      main.cpp:9:29: error: no matching function for call to 'QStringDecoder::EncodedData<const QByteArray&>::EncodedData(QString)'
          9 |        return QString("huh?");
            |                             ^
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            thiago Thiago Macieira
            jotik Jaak Ristioja
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes