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

QVariant.toJsonValue() should convert from number types

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.9.0 Beta 4
    • Core: Object Model
    • None

    Description

      This bug is an update for QTBUG-52097.

      On 5.9, QVariant::toJsonValue() works for Q... types but not for C number types (int ...).

      The actual implementation in qvariant.cpp call qVariantToHelper:

      QJsonValue QVariant::toJsonValue() const
      {
          return qVariantToHelper<QJsonValue>(d, handlerManager);
      }
      

      but all the methods like toInt call qNumVariantToHelper instead :

      int QVariant::toInt(bool *ok) const
      {
          return qNumVariantToHelper<int>(d, handlerManager, ok, d.data.i);
      }
      

       
      There is thus two flavours of q...VariantToHelper !

      As a workaround, we have to use QJsonValue::fromVariant() but the API could be more consistent.

      Attachments

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

        Activity

          People

            thiago Thiago Macieira
            fabricesalvaire fabrice salvaire
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes