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

Custom container layout broken in designer

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Not Evaluated
    • 4.6.1
    • 4.5.2
    • Tools: Designer
    • None
    • d1c5585faa066a6693c24600cf8a1c42a285fe3b

    Description

      I'm creating a plugin for a custom container. So far, after fiddling around, I could:

      • register my extention correctly (it's getting called)
      • specify my CustomWidgetInterface (works fine)

      Now, when using designer everything works fine except for the layout. When having a layout with equal margins uic generates a call to layout->setContentsMargins(0, 0, 0, 0); When the layout has different values in left, top, right or bottom direction, the code is OK.

      BTW, this is also seen in designer: in the edition view my custom container is setup correctly. When doing a preview, the layout is corrupted (ie. no margins).

      Steps to reproduce / test case:

      • Create a custom container plugin for designer.
      • In designer, create a Widget with the custom container, set a PushButton (or whatever in it) and add a layout. The layout is handled correctly. But when doing a preview, the layout is corrupted (no margins).

      More information:

      Here is an except of the ui file generated by designer.

      <widget class="pdgm::gui::ExpandableFrame" name="pdgm_gui_expandableframe"> 
      <property name="geometry"> 
      <rect> 
      <x>40</x> 
      <y>30</y> 
      <width>97</width> 
      <height>73</height> 
      </rect> 
      </property> 
      <widget class="QWidget" name="expandableFrameWidget"> 
      <layout class="QGridLayout" name="gridLayout"> 
      <property name="margin"> 
      <number>9</number> 
      </property> 
      <property name="spacing"> 
      <number>6</number> 
      </property> 
      <item row="0" column="0"> 
      <widget class="QPushButton" name="pushButton"> 
      <property name="text"> 
      <string>PushButton</string> 
      </property> 
      </widget> 
      </item> 
      </layout> 
      </widget> 
      </widget>
      

      This is the generated code using uic. Notice the culprit call to
      "gridLayout->setContentsMargins(0, 0, 0, 0);"

      pdgm_gui_expandableframe = new pdgm::gui::ExpandableFrame(Dialog); 
      pdgm_gui_expandableframe->setObjectName(QString::fromUtf8("pdgm_gui_expandableframe")); 
      pdgm_gui_expandableframe->setGeometry(QRect(40, 30, 97, 73)); 
      expandableFrameWidget = new QWidget(pdgm_gui_expandableframe); 
      expandableFrameWidget->setObjectName(QString::fromUtf8("expandableFrameWidget")); 
      expandableFrameWidget->setProperty("native", QVariant(true)); 
      gridLayout = new QGridLayout(expandableFrameWidget); 
      #ifndef Q_OS_MAC 
      gridLayout->setSpacing(6); 
      #endif 
      #ifndef Q_OS_MAC 
      gridLayout->setMargin(9); 
      #endif 
      gridLayout->setObjectName(QString::fromUtf8("gridLayout")); 
      gridLayout->setContentsMargins(0, 0, 0, 0); // ARGGGG, why this one ? 
      pushButton = new QPushButton(expandableFrameWidget); 
      pushButton->setObjectName(QString::fromUtf8("pushButton")); 
      
      gridLayout->addWidget(pushButton, 0, 0, 1, 1);
      

      BTW, replacing in the ui file:

      <widget class="QWidget" name="expandableFrameWidget">
      

      with

      <widget class="QWidget" name="expandableFrameWidget" native="true">
      

      make things work correctly.

      Attachments

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

        Activity

          People

            kleint Friedemann Kleint
            sthomass Stian Sandvik Thomassen (closed Nokia identity) (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes