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

QLocale::formattedDataSize should be const

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Done
    • Affects Version/s: 5.11.1
    • Fix Version/s: 5.13.0 Alpha 1
    • Component/s: Core: Locales (i18n)
    • Labels:
      None
    • Environment:
      Linux 4.18.0-amd64, Debian testing
    • Platform/s:
      All
    • Commits:
      8b7a4b8dd8ffd4c55fd013179242ecd42441d6a9 (qt/qtbase/dev)

      Description

      QLocale::formattedDataSize is marked as mutable, meaning in places like item delegates where it may be useful one needs to make a const_cast to strip the qualifier. Example follows:

      class MyDelegate : public QStyledItemDelegate
      {
      public:
          QString displayText(const QVariant &, const QLocale &) const override;
      };
      QString MyDelegate::displayText(const QVariant & value, const QLocale & locale) const
      {
          return locale.formattedDataSize(value.toDouble()); 
          // error: passing 'const QLocale' as 'this' argument discards qualifiers [-fpermissive]
      }

       

        Attachments

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

          Activity

            People

            Assignee:
            chehrlic Christian Ehrlicher
            Reporter:
            kshegunov Konstantin Shegunov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes