osx - QPushButton creates empty space on Mac OS X resulting in ugly layouts -


i moved mac os x , noticed dialogs in 1 of applications kind of strange... have several dialogs simple form has configurable paths:

label: <qlineedit> <qpushbutton (opens file dialog)>
label: ...

the dialog organized in qgridlayout, looks fine on ubuntu:
dialog on ubuntu

on mac os x there big empty space below qpushbuttons row makes whole thing strange:
dialog on os x

i found bug report apparently silently closed: https://bugreports.qt.io/browse/qtbug-2699

ui code:

<?xml version="1.0" encoding="utf-8"?> <ui version="4.0">  <class>dialog</class>  <widget class="qdialog" name="dialog">   <property name="geometry">    <rect>     <x>0</x>     <y>0</y>     <width>431</width>     <height>235</height>    </rect>   </property>   <property name="sizepolicy">    <sizepolicy hsizetype="preferred" vsizetype="fixed">     <horstretch>0</horstretch>     <verstretch>0</verstretch>    </sizepolicy>   </property>   <property name="windowtitle">    <string>pdf export</string>   </property>   <property name="windowicon">    <iconset resource="resources.qrc">     <normaloff>:/images/images/application-pdf.png</normaloff>:/images/images/application-pdf.png</iconset>   </property>   <layout class="qvboxlayout" name="verticallayout">    <item>     <layout class="qgridlayout" name="gridlayout">      <item row="0" column="1">       <widget class="qlineedit" name="texpath">        <property name="readonly">         <bool>true</bool>        </property>       </widget>      </item>      <item row="1" column="0">       <widget class="qlabel" name="label">        <property name="text">         <string>auszubildender:</string>        </property>        <property name="buddy">         <cstring>traineename</cstring>        </property>       </widget>      </item>      <item row="1" column="1" colspan="2">       <widget class="qlineedit" name="traineename"/>      </item>      <item row="2" column="0">       <widget class="qlabel" name="label_2">        <property name="text">         <string>ausbilder:</string>        </property>        <property name="buddy">         <cstring>instructorname</cstring>        </property>       </widget>      </item>      <item row="2" column="1" colspan="2">       <widget class="qlineedit" name="instructorname"/>      </item>      <item row="3" column="0">       <widget class="qlabel" name="label_5">        <property name="text">         <string>name der firma:</string>        </property>        <property name="buddy">         <cstring>companyname</cstring>        </property>       </widget>      </item>      <item row="3" column="1" colspan="2">       <widget class="qlineedit" name="companyname"/>      </item>      <item row="4" column="0">       <widget class="qlabel" name="label_3">        <property name="text">         <string>datum der unterschriften:</string>        </property>        <property name="buddy">         <cstring>dateedit</cstring>        </property>       </widget>      </item>      <item row="4" column="1" colspan="2">       <widget class="qdateedit" name="dateedit">        <property name="displayformat">         <string>dd.mm.yyyy</string>        </property>        <property name="calendarpopup">         <bool>true</bool>        </property>       </widget>      </item>      <item row="0" column="2">       <widget class="qpushbutton" name="browsebutton">        <property name="text">         <string/>        </property>        <property name="icon">         <iconset resource="resources.qrc">          <normaloff>:/images/images/document-open.png</normaloff>:/images/images/document-open.png</iconset>        </property>       </widget>      </item>      <item row="0" column="0">       <widget class="qlabel" name="label_4">        <property name="text">         <string>pfad zum tex-template:</string>        </property>        <property name="buddy">         <cstring>texpath</cstring>        </property>       </widget>      </item>     </layout>    </item>    <item>     <layout class="qhboxlayout" name="horizontallayout">      <item>       <spacer name="horizontalspacer">        <property name="orientation">         <enum>qt::horizontal</enum>        </property>        <property name="sizehint" stdset="0">         <size>          <width>40</width>          <height>20</height>         </size>        </property>       </spacer>      </item>      <item>       <widget class="qpushbutton" name="cancelbutton">        <property name="text">         <string>abbrechen</string>        </property>       </widget>      </item>      <item>       <widget class="qpushbutton" name="generatebutton">        <property name="text">         <string>pdf generieren...</string>        </property>        <property name="icon">         <iconset resource="resources.qrc">          <normaloff>:/images/images/arrow-right.png</normaloff>:/images/images/arrow-right.png</iconset>        </property>       </widget>      </item>     </layout>    </item>   </layout>  </widget>  <tabstops>   <tabstop>texpath</tabstop>   <tabstop>browsebutton</tabstop>   <tabstop>traineename</tabstop>   <tabstop>instructorname</tabstop>   <tabstop>companyname</tabstop>   <tabstop>dateedit</tabstop>   <tabstop>cancelbutton</tabstop>   <tabstop>generatebutton</tabstop>  </tabstops>  <resources>   <include location="resources.qrc"/>  </resources>  <connections>   <connection>    <sender>cancelbutton</sender>    <signal>clicked()</signal>    <receiver>dialog</receiver>    <slot>reject()</slot>    <hints>     <hint type="sourcelabel">      <x>246</x>      <y>221</y>     </hint>     <hint type="destinationlabel">      <x>133</x>      <y>152</y>     </hint>    </hints>   </connection>  </connections> </ui> 

is there way fix this?

you should using qbuttonbox buttons, not discrete buttons in custom layout. you'll need add pdf generation button manually.

as temporary workaround, need reduce bottom margin size on os x. it'll fixed eventually.

dialog::dialog(qwidget *parent) :     qdialog(parent),     ui(new ui::widget) {     ui->setupui(this);     qpushbutton * btn = new qpushbutton(tr("pdf generieren..."));     btn->seticon(qicon(":/images/images/arrow-right.png"));     ui->buttonbox->addbutton(btn, qdialogbuttonbox::acceptrole); #if (qt_version <= qt_version_check(5, 1, 1)) && defined(qt_os_mac)     qmargins margins = layout()->contentsmargins();     margins.setbottom(margins.bottom() - 6);     layout()->setcontentsmargins(margins); #endif } 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -