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

QVariant::convert() cannot deal with conversion across subclasses when using Q_GADGET

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.5.0 Beta
    • Core: Other
    • None

    Description

      Assume the following setup:

      class A {
          Q_GADGET
      };
      
      class B : public A {
          Q_GADGET
      };
      
      class Foo: public QObject {
          Q_PROPERTY(A propA READ propA WRITE setPropA)
      };
      

      and in QML we try to execute the following snippet:

      Foo {
          propA: b // whereby b is an instance of gadget B
      }
      

      This fails to work as QQmlProperty cannot convert an instance of B to and instance of A. More precise QVariant::convert() relies on Q_OBJECT to work but it never got this treatment for Q_GADGET.

      QVariant::canConvert and QVariant::convert should implement the conversion between two Q_GADGET if one is derived by the other.

      Attachments

        For Gerrit Dashboard: QTBUG-46232
        # Subject Branch Project Status CR V

        Activity

          People

            Unassigned Unassigned
            ablasche Alex Blasche
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes