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

Allow Q_PROPERTY to parse struct/class member using MEMBER

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • P4: Low
    • None
    • 5.5.0
    • Build tools: moc
    • None

    Description

      Currently if you create a property as:

      Q_PROPERTY(int test MEMBER testStruct.testNotWorking)
      struct testStruct_t{
      int testNotWorking;
      }
      testStruct_t testStruct;
      int testWorking;
      

      moc indicates a parse error at "testStruct"

      generated code by MOC if i access testWorking instead is:

          else if (_c == QMetaObject::ReadProperty) {
              MyItem *_t = static_cast<MyItem *>(_o);
              Q_UNUSED(_t)
              void *_v = _a[0];
              switch (_id) {
              case 0: *reinterpret_cast< int*>(_v) = _t->testWorking; break;
              default: break;
              }
          } else if (_c == QMetaObject::WriteProperty) {
              MyItem *_t = static_cast<MyItem *>(_o);
              Q_UNUSED(_t)
              void *_v = _a[0];
              switch (_id) {
              case 0:
                  if (_t->testWorking != *reinterpret_cast< int*>(_v)) {
                      _t->testWorking = *reinterpret_cast< int*>(_v);
                  }
                  break;
              default: break;
              } 

      i think it must allow to access a struct/class, C++ compiler will give the error if the member is private, but i don't see why it should be forbidden at parse level.

      But it would allow to pack properties together on a standard layout

      Attachments

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

        Activity

          People

            Unassigned Unassigned
            bnogal Benjamín Nogal
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes