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

[REG] Non-Singlebit Q_FLAGS not exposed correctly in property declarations

    XMLWordPrintable

Details

    • Linux/X11
    • f7930126a (dev), 50e661d3b (6.6), 9be1da763 (6.5)

    Description

      Actually noticed this while writing another bugreport:

      I have a simple use case for flags in qml:

      class ControlFlags : public QObject 
      {
          Q_OBJECT
          QML_ELEMENT
          QML_UNCREATABLE("Flag Container Class")
      
      public:
          ControlFlags() = delete;
      
          enum Option {       
              ControlA = 0x1,
              ControlB = 0x2,       
              Both = ControlA | ControlB   
          }
      
          Q_DECLARE_FLAGS(Options, Option)
          Q_FLAG(Option)
      };
      
      Q_DECLARE_OPERATORS_FOR_FLAGS(ControlFlags::Options)
      

      using this in qml is fine up to the point, where we use Both. Both is available in qt creator and has meta information generated, but accessing it always gives -1.

      So in qml, writing ControlFlags.ControlA | ControlFlags.ControlB != ControlFlags.Both.

      In my use case, I have a component, which has flags as required property, when I use it like this:

      Item {
          requiredFlags: ControlFlags.Both 
      }
      

      I get an invalid configuration back

      Attachments

        1. bisect.log
          2 kB
        2. QTBUG-114326.tar.gz
          4 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            fabiankosmale Fabian Kosmale
            r.vitanov Rosen Vitanov
            Votes:
            1 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes