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

QFormBuilder - Saves all children to file making the file unsuited for reading

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 6.2.0
    • Tools: Designer
    • None
    • All

    Description

      QFormBuilder saves all children of widgets

      Just to be clear....

      The ui-files imported (created by designer) then exported and imported again by QFormBuilder should result in having the same build as the original.

      This last statement is not true for the specified Qt-version and those before.

      I found some reports relating to the same issue but were never solved:

      The simplest example is to create a form using a QWidget as the root
      and a QLineEdit in it having clearButtonEnabled set to true.

      QFormBuilder saves all attributes even when default values are present.
      Also some properties are not supported yet it seems.
      But that is not a problem but would be nice if those were solved. 

      Designer: The property inputMethodHints could not be written. The type QFlags<Qt::InputMethodHint> is not supported yet.
      Designer: The property focusPolicy could not be written. The type Qt::FocusPolicy is not supported yet.
      Designer: The property layoutDirection could not be written. The type Qt::LayoutDirection is not supported yet.
      Designer: The property windowModality could not be written. The type Qt::WindowModality is not supported yet.

       The provided single file application parses the XML of the ui-file.

      ====================(Before)=======================
      Element: "widget" "class" "QWidget"
      Element: "widget" "class" "QLabel"
      Element: "widget" "class" "QLineEdit"
      Element: "property" "name" "buddy"
      ===================================================

       The by the the QFormBuilder saved XML is parsed the same way. 

      ====================(After)=======================
      Element: "widget" "class" "QWidget"
      Element: "widget" "class" "QLabel"
      Element: "widget" "class" "QLineEdit"
      Element: "widget" "class" "QLineEditIconButton"
      ==================================================

      As you can see the QLineEdit has a QLineEditIconButton child.
      Also the buddy property of the QLabel is not saved.

      My Suggested options for a possible Solution

      1. Add a virtual "isFinal()" method to the QWidget class which determines if the class' children should be saved/stored as well.
        This also will help when creating a custom widget which contain several child widget buttons et cetera.
      2. Add protected virtual method "bool isFinal(QWidget* widget)" to QFormBuilder which is queried to determine if a widget's children should be saved or not.
        Same solution with a virtual method for each property "bool saveProperty(QObject*, const Qstring& name, const QVariant&) of a saved object would be nice to have too.

      I think #2 solution would be the least extensive and only concerns the Qt::Designer.

      My Current Work-around (my code)

      I put the huge saved XML in a QDomDocumentand remove all children from all widget classes that are multi inherited from my own class called "ObjectExtension".
      Remove all properties that have default values.

      To fix above buddy property I added the QLineEdit to a static list of classes who's
      children are not to be saved. The missing "budy" property I also add manually to the XML Dom.

       

      Attachments

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

        Activity

          People

            Unassigned Unassigned
            arjan Arjan van Olphen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes