so have small program i've made qt designer, , part, it's fine. there 1 niggling problem;
i have qlabel
, text long, want make text wrap. should simple task.
here looks no wordwrap
and fine. when text gets long, puts in horrible scroll bar. don't want this, enable wordwrap. happens:
which @ first thought qt designer being crap, compiled , run hoping go away. happens, thought reasonable assumption.
it wasn't.
why hell happening?!
edit: enabling word wrap manually in widget initialiser causes same behaviour - it's not caused qt designer, it's issue elsewhere. appreciated!
here content of ui file:
<?xml version="1.0" encoding="utf-8"?> <ui version="4.0"> <class>mainwindow</class> <widget class="qmainwindow" name="mainwindow"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>705</width> <height>347</height> </rect> </property> <property name="windowtitle"> <string>title</string> </property> <property name="windowicon"> <iconset resource="icons.qrc"> <normaloff>:/icons/icons/3/bonus48x48_20.png</normaloff>:/icons/icons/3/bonus48x48_20.png</iconset> </property> <widget class="qwidget" name="centralwidget"> <layout class="qgridlayout" name="gridlayout" columnstretch="0,1,1"> <item row="1" column="0"> <widget class="qlabel" name="label_molecule"> <property name="text"> <string>molecule:</string> </property> </widget> </item> <item row="1" column="1"> <widget class="qlineedit" name="lineedit_molecule"/> </item> <item row="2" column="0" colspan="2"> <widget class="qtoolbox" name="toolbox_modeldetails"> <property name="currentindex"> <number>0</number> </property> <widget class="qwidget" name="page_isomer"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>373</width> <height>154</height> </rect> </property> <attribute name="label"> <string>isomer</string> </attribute> <layout class="qvboxlayout" name="verticallayout"> <item> <widget class="qlistwidget" name="listwidget_isomers"> <property name="alternatingrowcolors"> <bool>true</bool> </property> </widget> </item> </layout> </widget> <widget class="qwidget" name="page_model"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>357</width> <height>231</height> </rect> </property> <attribute name="label"> <string>model</string> </attribute> <layout class="qvboxlayout" name="verticallayout_2" stretch="0,0"> <item> <widget class="qlistwidget" name="listwidget_models"> <property name="sizepolicy"> <sizepolicy hsizetype="expanding" vsizetype="expanding"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> <property name="font"> <font> <stylestrategy>preferdefault</stylestrategy> </font> </property> <property name="linewidth"> <number>1</number> </property> <property name="alternatingrowcolors"> <bool>true</bool> </property> </widget> </item> <item> <widget class="qlabel" name="label_description"> <property name="text"> <string>howdy!</string> </property> <property name="wordwrap"> <bool>true</bool> </property> </widget> </item> </layout> </widget> <widget class="qwidget" name="page_basisset"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>373</width> <height>154</height> </rect> </property> <attribute name="label"> <string>basis set</string> </attribute> <layout class="qvboxlayout" name="verticallayout_3"> <item> <widget class="qlistwidget" name="listwidget_basissets"> <property name="alternatingrowcolors"> <bool>true</bool> </property> </widget> </item> </layout> </widget> </widget> </item> <item row="3" column="0" colspan="3"> <layout class="qhboxlayout" name="horizontallayout_buttons"> <item> <spacer name="horizontalspacer_buttons"> <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="pushbutton_save"> <property name="text"> <string>save input file</string> </property> </widget> </item> <item> <widget class="qpushbutton" name="pushbutton_open"> <property name="text"> <string>open</string> </property> </widget> </item> </layout> </item> <item row="1" column="2" rowspan="2"> <widget class="qgroupbox" name="groupbox_moleculeviewer"> <property name="title"> <string>molecule</string> </property> </widget> </item> </layout> </widget> <widget class="qstatusbar" name="statusbar"/> </widget> <resources> <include location="icons.qrc"/> </resources> <connections/> </ui>
why nesting widgets (the qlabel
, qlistwidget
) qwidget
?
that's why getting 2 scrollbars. 1 qlistwidget
, because has more items can viewed. , 1 parent qwidget
.
you should using layouts.
this have:
should this:
Comments
Post a Comment