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

Cannot set the property type to a custom Q_GADGET object

    XMLWordPrintable

Details

    • macOS
    • 5a908de8b7e772e78adb30cc3205c7cf5bd622f5

    Description

      When a struct is marked with `Q_GADGET`, we are able to return a value from a function and assign it to a `property var` type, but we cannot declare `property MyCustomGadget`.

      See attached minimal sample.

       

      Window {
          id: root
      
          property ValueType vt
          property var vt2
      
          width: 500
          height: 500
          visible: true
          Component.onCompleted: {
              console.log(root.vt) // Prints null
          }
      
          Playground {
              id: pl
          }
      
          Button {
              text: "10"
              onClicked: {
                  // Doesn't work
                  root.vt = pl.value()
                  // Works
                  root.vt2 = pl.value()
              }
          }
      }
      

       

      Attachments

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

        Activity

          People

            ulherman Ulf Hermann
            uzumcuf Furkan Uzumcu
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes