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

QMetaProperty's isDesignable() allow even those properties which are not shown in Qt Designer.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • P2: Important
    • None
    • 5.12.2
    • None
    • All

    Description

      For a Qt Creator plugin project, I needed to get only those properties of the widgets which Qt Designer shows in the Property Editor.

      I read the topic Reading and Writing Properties with the Meta-Object System from the docs at https://doc.qt.io/qt-5/properties.html, I successfully read the properties of QPushButton using the following code: 

       

      QObject *object = new QPushButton;
      const QMetaObject *metaobject = object->metaObject();
      int count = metaobject->propertyCount();
      for (int i=0; i<count; ++i) {
          QMetaProperty metaproperty = metaobject->property(i);
          qDebug()<<qPrintable(QString(metaproperty.name()) + " : " + QString(metaproperty.typeName()));
      }
      

       I noticed that the above code printed not only those properties which Qt Designer displays for the QPushButton in the Property Editor but also many other too!

      In the docs i found isDesignable https://doc.qt.io/Qt-5/qmetaproperty.html#isDesignable ,
      As the docs says here https://doc.qt.io/qt-5/properties.html that:

      "The DESIGNABLE attribute indicates whether the property should be visible in the property editor of GUI design tool (e.g., Qt Designer). "

      So I included metaproperty.isDesignable() check in the code so that my code may print only those properties which are intended to be visible in the Qt  Designer:

      QObject *object = new QPushButton;
      const QMetaObject *metaobject = object->metaObject();
      int count = metaobject->propertyCount();
      for (int i=0; i<count; ++i) {
          QMetaProperty metaproperty = metaobject->property(i);
          if( metaproperty.isDesignable() ) {
              qDebug()<<qPrintable(QString(metaproperty.name()) + " : " + QString(metaproperty.typeName()));
          }
      }
      

      But even with this check I noticed that many properties get printed which are not shown in the Qt Designer!
      For example, these properties are shown which I don't find them in Qt Designer: 
      windowModality, frameGeometry, normalGeometry, childrenRect, windowIcon, windowIconText, windowOpacity, windowModified, etc.

       

      Attachments

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

        Activity

          People

            thiago Thiago Macieira
            eager1 Shujaat Khan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes