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

Qt Designer Ignores <layoutdefault>; expands <property name="margin">

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: P2: Important
    • Resolution: Unresolved
    • Affects Version/s: 5.10.1
    • Fix Version/s: None
    • Component/s: Tools: Designer
    • Labels:
      None
    • Environment:
    • Platform/s:
      iOS/tvOS/watchOS

      Description

      I've been working on a project and I'm trying to organize my layouts to not be as verbose about specifying the margins and spacing of layouts. I find the default margins of "13" and spacing of "8" to be too big, and thus I like "4" for both. Inspecting my *.ui file, I noticed that even when I set all 4 margins to the same value, they are actually much more verbose and repeated 4 times. If I set only <property name="margin"> manually in the *.ui file, it works, but when I reopen it in the designer then it's immediately expanded back into 4 separate properties for left/top/right/bottom.

      I also discovered, and would like to make use of <layoutdefault spacing="4" margin="4"/> but it only has an effect at runtime, and if my layouts specify no spacing or margins, Qt Designer will show me still "13" and "8" even though it is correctly the value "4" at runtime. Qt Designer has the same behavior with Tools->Form Editor->Preview (it uses the "13" margins and "8" spacing so layoutdefault has no effect there either). I'm reporting this because I feel it must be a regression as this has worked for me in previous Qt Creator versions. I don't understand why Qt Designer would show me the form ignoring the default layout spacing and margins I've explicitly set (from Tools->Form Editors->Form Settings...).

      I found in the QLayout documentation that spacing is actually supposed to be inherited if not set:
      http://doc.qt.io/qt-5/qlayout.html#spacing-prop
      I found in the same QLayout docs that margins are supposed to be determined by the style:
      http://doc.qt.io/qt-5/qlayout.html#contentsMargins

      Steps to reproduce:
      1) Create a new layout test project
      2) Specify the default layout margins and spacing in the Form Settings (which adds <layoutdefault> to the *.ui file)
      3) Add a child layout and other widgets with some child layouts to the form
      4) Examine the child layout and widget margins/spacing using the Designer inspector (notice that they are not what you set in the Form Settings as the default)
      5) Compile and run the project and notice that the form will have the margins and spacing you specified in the Form Settings.

        Attachments

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

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            RobertBColton Robert B. Colton
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes