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

QVariant cannot convert long/ulong to string

    XMLWordPrintable

    Details

    • Platform/s:
      All

      Description

      Consider a simple example:

          const auto tryType = [](int targetTypeId)
          {
              auto v = QVariant::fromValue(123);
              Q_ASSERT(v.convert(targetTypeId));
              qDebug() << v << "can convert to string:" << v.canConvert(QMetaType::QString);
          };
      
          tryType(QMetaType::Short);
          tryType(QMetaType::UShort);
          tryType(QMetaType::Int);
          tryType(QMetaType::UInt);
          tryType(QMetaType::Long);
          tryType(QMetaType::ULong);
          tryType(QMetaType::LongLong);
          tryType(QMetaType::ULongLong);
      

      We can expect to see true for all types but instead we see:

      QVariant(short, 123) can convert to string: true
      QVariant(ushort, 123) can convert to string: true
      QVariant(int, 123) can convert to string: true
      QVariant(uint, 123) can convert to string: true
      QVariant(long, 123) can convert to string: false
      QVariant(ulong, 123) can convert to string: false
      QVariant(qlonglong, 123) can convert to string: true
      QVariant(qulonglong, 123) can convert to string: true

        Attachments

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

          Activity

            People

            Assignee:
            thiago Thiago Macieira
            Reporter:
            nkrupenko.nvidia Nikita Krupenko
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes