How to resize groupbox in QT Designer - qt

I'm not sure if this is a bug or the way QT Designer was designed but I cannot resize any element on a QT widget with the 'blue boxes' one would expect to resize with. I also am not allowed to edit the minimum/maximum sizes to anything but zero. Are there some settings I need to change or is this just a bug?
.UI file:
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MeshGeneratorWidget</class>
<widget class="QWidget" name="MeshGeneratorWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>927</width>
<height>789</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Mesh Generator</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="AlignmentSceneviewerWidget" name="sceneviewer_widget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>4</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<widget class="QDockWidget" name="dockWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>-10</y>
<width>492</width>
<height>771</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>492</width>
<height>557</height>
</size>
</property>
<property name="features">
<set>QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable</set>
</property>
<property name="allowedAreas">
<set>Qt::AllDockWidgetAreas</set>
</property>
<property name="windowTitle">
<string>Control Panel</string>
</property>
<widget class="QWidget" name="dockWidgetContents">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAsNeeded</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_2">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>472</width>
<height>388</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QGroupBox" name="time_groupBox">
<property name="title">
<string>Time:</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="timeValue_doubleSpinBox">
<property name="maximum">
<double>12000.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QCheckBox" name="timeLoop_checkBox">
<property name="text">
<string>Loop</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="timeValue_label">
<property name="text">
<string>Time value:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="timePlayStop_pushButton">
<property name="text">
<string>Play</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>234</height>
</size>
</property>
<property name="title">
<string>Adjust Data</string>
</property>
<widget class="QSlider" name="adjustData_Slider">
<property name="geometry">
<rect>
<x>20</x>
<y>50</y>
<width>431</width>
<height>22</height>
</rect>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="minimum">
<number>-200</number>
</property>
<property name="maximum">
<number>200</number>
</property>
<property name="singleStep">
<number>1</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="invertedAppearance">
<bool>false</bool>
</property>
</widget>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>410</x>
<y>70</y>
<width>55</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>+2s</string>
</property>
</widget>
<widget class="QLabel" name="label_4">
<property name="geometry">
<rect>
<x>30</x>
<y>70</y>
<width>55</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>-2s</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_3">
<property name="geometry">
<rect>
<x>60</x>
<y>170</y>
<width>201</width>
<height>24</height>
</rect>
</property>
<property name="text">
<string>View data with video</string>
</property>
</widget>
<widget class="QPushButton" name="viewVideo_button">
<property name="geometry">
<rect>
<x>180</x>
<y>90</y>
<width>121</width>
<height>24</height>
</rect>
</property>
<property name="text">
<string>View Video</string>
</property>
</widget>
</widget>
</item>
<item>
<widget class="QGroupBox" name="video_groupBox">
<property name="title">
<string>Video:</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="frameIndex_label">
<property name="text">
<string>Frame index:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="framesPerSecond_spinBox">
<property name="minimum">
<number>1</number>
</property>
<property name="value">
<number>25</number>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="frameIndex_spinBox">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>10000</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="framesPerSecond_label">
<property name="text">
<string>Frames per second:</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QFrame" name="numFrames_frame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="numFrames_label">
<property name="text">
<string># frames:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="numFramesValue_label">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>GroupBox</string>
</property>
<widget class="QLineEdit" name="lineEdit">
<property name="geometry">
<rect>
<x>200</x>
<y>0</y>
<width>113</width>
<height>20</height>
</rect>
</property>
</widget>
</widget>
</item>
<item>
<widget class="QGroupBox" name="blackfynn_groupBox">
<property name="title">
<string>Blackfynn:</string>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="6" column="2">
<widget class="QPushButton" name="downloadData_button">
<property name="text">
<string>Download Data</string>
</property>
</widget>
</item>
<item row="5" column="3">
<widget class="QPushButton" name="blackfynnTimeSeries_pushButton">
<property name="toolTip">
<string>Retrieve time series</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset>
<normaloff>:/meshgeneratorstep/images/download-icon-blue.png</normaloff>:/meshgeneratorstep/images/download-icon-blue.png</iconset>
</property>
</widget>
</item>
<item row="9" column="2">
<widget class="QLineEdit" name="exportDirectory_lineEdit">
<property name="text">
<string>C:\Users\jkho021\Projects\MPB</string>
</property>
</widget>
</item>
<item row="7" column="2">
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Export for WebGL</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QComboBox" name="blackfynnDatasets_comboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="blackfynnDatasets_label">
<property name="text">
<string>Datasets:</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QPushButton" name="blackfynnDatasets_pushButton">
<property name="toolTip">
<string>Retrieve datasets</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset>
<normaloff>:/meshgeneratorstep/images/download-icon-blue.png</normaloff>:/meshgeneratorstep/images/download-icon-blue.png</iconset>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QComboBox" name="blackfynnTimeSeries_comboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="blackfynnTimeSeries_label">
<property name="text">
<string>Time series:</string>
</property>
</widget>
</item>
<item row="8" column="2">
<widget class="QPushButton" name="pushButton_2">
<property name="text">
<string>Upload to Blackfynn</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="4">
<widget class="QGroupBox" name="blackfynnProfiles_groupBox">
<property name="title">
<string>Profiles:</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QComboBox" name="profiles_comboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="addProfile_pushButton">
<property name="toolTip">
<string>Add profile</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset>
<normaloff>:/meshgeneratorstep/images/plus-icon-green-th.png</normaloff>:/meshgeneratorstep/images/plus-icon-green-th.png</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="0">
<widget class="QFrame" name="frame_2">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="leftMargin">
<number>3</number>
</property>
<property name="topMargin">
<number>3</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item>
<widget class="QPushButton" name="viewAll_button">
<property name="text">
<string>View All</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="done_button">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Done</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>AlignmentSceneviewerWidget</class>
<extends>QWidget</extends>
<header>opencmiss/zincwidgets/alignmentsceneviewerwidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="resources.qrc"/>
</resources>
<connections/>
</ui>

Not a bug. As ekhumoro mentioned above, you can't resize widgets that are contained in a layout (not with Designer, anyway). You need to break the layout, then resize, then reapply the layout. Kind of a pain, I know, but after awhile you get used to it. The toolbar buttons make this go a lot faster, BTW.

Related

Qt6 migration - UIC generated code fails to compile (connect slots) - updated

I'm trying to port my project from Qt5 to Qt6.
My problem is that UIC generated code looks like this:
QObject::connect(SelectHome, &QToolButton::clicked, toQPSQLSettingUI, qOverload<>(&QWidget::selectHome));
MSVC2019 compilations fails with:
ui_toqpsqlsettingui.h(74,101): error C2039: 'selectHome': is not a member of 'QWidget'
C:\Qt\6.0.4\msvc2019_64\include\QtWidgets\qcompleter.h(57): message : see declaration of 'QWidget'
C:\Users\I542264\source\repos\tora\src\ui_toqpsqlsettingui.h(74,1): error C2065: 'selectHome': undeclared identifier
See the target is method is QWidget::selectHome, so IMHO MSVC is right: QWidget does not have method selectHome. But target should be sub-class method toQPSQLSettingUI::selectHome
Complete source is here. Initially created for Qt2, migrated to Qt3=>Qt4=>Q5.
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>toQPSQLSettingUI</class>
<widget class="QWidget" name="toQPSQLSettingUI">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<height>517</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>600</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string>Form1</string>
</property>
<layout class="QGridLayout">
<property name="margin">
<number>11</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<item row="0" column="1" colspan="2">
<widget class="QLineEdit" name="PGSQL_HOME"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="TextLabel6_2_2_2">
<property name="toolTip">
<string>The default dateformat to use when querying the database.</string>
</property>
<property name="text">
<string>PgSQL home</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
<property name="buddy">
<cstring>PGSQL_HOME</cstring>
</property>
</widget>
</item>
<item row="1" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="3">
<widget class="QToolButton" name="SelectHome">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>PGSQL_HOME</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>SelectHome</sender>
<signal>clicked()</signal>
<receiver>toQPSQLSettingUI</receiver>
<slot>selectHome()</slot>
<hints>
<hint type="sourcelabel">
<x>606</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>314</x>
<y>258</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<signal>signal1()</signal>
</slots>
</ui>

QFormLayout does not expand widget full height to maximum widget height

I have an issue with getting a QTreewidget full height inside a QFormLayout. I'm on Windows 10 and use QT 5.7
Things I tried:
all possible Vertical policy's without success. Change the
FieldGrowthPolicy of the layout to AllNonFixedFieldsGrow
Use another widget, all fail to make this work
That's all the options I found to possibly make this work.
Here's what I try to achieve:
Here's my ui file:
<?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>760</width>
<height>747</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Please grow the treeview:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QTreeWidget" name="treeWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<column>
<property name="text">
<string notr="true">1</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
Please read the Qt tutorials about layouts.
I added a two layouts and a spacer to your ui file.
<?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>489</width>
<height>215</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Please grow the treeview:</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QTreeWidget" name="treeWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<column>
<property name="text">
<string notr="true">1</string>
</property>
</column>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
Based on this answer: Qt formlayout not expanding qplaintextedit vertically which worked for me, setting the Vertical Stretch attribute to something other than 0 should do the trick.

Can't get a widget to grow properly when I resize the window

I made a form that looks like this: . The .ui is below.
The QTextEdit on the right is the only widget that has it's horizontal size policy set to Expanding. All the other widgets are either Preferred or Minimum. Yet when I resize the window horizontally, the text edit is the only widget that does not grow. It stays the same size while all the other widgets expand horizontally.
I guess there's something that I don't understand about how all of that works. What do I have to do to make the text edit expand when I resize the window?
.ui file
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWidget</class>
<widget class="QWidget" name="MainWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>634</width>
<height>303</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="3" column="4" rowspan="7" colspan="2">
<widget class="QTextEdit" name="textEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>300</width>
<height>0</height>
</size>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Data written:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLabel" name="readSpeedLabel">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Write speed:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Test Mode:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="5" column="3">
<widget class="QLabel" name="dataWrittenLabel">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Read speed:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="4" column="1" colspan="3">
<widget class="QPushButton" name="testModePushButton">
<property name="text">
<string>Select testing mode</string>
</property>
</widget>
</item>
<item row="9" column="2" colspan="2">
<widget class="QPushButton" name="startStopButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Start test</string>
</property>
</widget>
</item>
<item row="3" column="1" colspan="3">
<widget class="QPushButton" name="devicePushButton">
<property name="text">
<string>Select device</string>
</property>
</widget>
</item>
<item row="7" column="3">
<widget class="QLabel" name="ETALabel">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLabel" name="writeSpeedLabel">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="7" column="2">
<widget class="QLabel" name="label_11">
<property name="text">
<string>ETA:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="6" column="3">
<widget class="QLabel" name="dataReadLabel">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Data Read:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="8" column="0" colspan="4">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Device:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
It is the QLabel items which are messing your layout.
Set the horizontal size policy to Fixed for every QLabel and it works.
Now the answer to why QLabels with Preferred are growing faster than the QTextEdit with an Expanding policy, I do not know. Especially when changing Preferred to Fix solves the problem.
Qt documentation states :
QSizePolicy::Expanding The widget can make use of extra space, so it should get as much space as possible.
QSizePolicy::Preferred The widget can be expanded, but there is no advantage to it being larger than sizeHint().
QSizePolicy::Fixed The QWidget::sizeHint() is the only acceptable alternative, so the widget can never grow or shrink.
Looking at this, it seems that a widget with Preferred would not grow bigger than sizeHint() when next to another widget with Expanding. But in your case labels behave like they have the priority over the text edit.
Note that this does not seem to be the case for QPushButton.
It looks like a bug to me.

adding a qwidget into QMainWindow as central widget

I created a Qwidget in QtCreator and want to put it into my QMainWindow as central widget. Here is the line that I do it inside the constructor of QMainWindow.
q = new QWidget();
setCentralWidget(q);
ui->setupUi(q);
In the photo below you can see how my qWidget looks like.
However after adding it into QMainWindow thats how it looks like
Here you can find .ui file. What might be the problem?
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QWidget" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>785</width>
<height>600</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>763</width>
<height>600</height>
</size>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<widget class="MainGlWidget" name="MainScreen" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>640</width>
<height>480</height>
</size>
</property>
<property name="cursor">
<cursorShape>OpenHandCursor</cursorShape>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<widget class="SideGlWidget" name="widget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>120</width>
<height>120</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50000</width>
<height>50000</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>751</width>
<height>64</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QPushButton" name="pushButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>30</horstretch>
<verstretch>30</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::ClickFocus</enum>
</property>
<property name="text">
<string>OFF</string>
</property>
<property name="icon">
<iconset>
<normaloff>off.png</normaloff>
<normalon>on.jpg</normalon>off.png</iconset>
</property>
<property name="iconSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="Wifi">
<property name="text">
<string>Wifi Signal</string>
</property>
</widget>
</item>
<item>
<widget class="QProgressBar" name="wifiProgressBar">
<property name="value">
<number>95</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="BatteryLabel">
<property name="text">
<string>Battery</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QProgressBar" name="BatteryPB">
<property name="value">
<number>100</number>
</property>
<property name="textDirection">
<enum>QProgressBar::TopToBottom</enum>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>MainGlWidget</class>
<extends>QWidget</extends>
<header>MainGlWidget.h</header>
<container>1</container>
<slots>
<slot>setXRotation(int)</slot>
<slot>setZRotation(int)</slot>
<slot>setYRotation(int)</slot>
</slots>
</customwidget>
<customwidget>
<class>SideGlWidget</class>
<extends>QWidget</extends>
<header>SideGlWidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
You should use a top level layout to arrange your child layout elements horizontalLayout and horizontalLayout_4.
Here is our .ui file fixed:
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QWidget" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>785</width>
<height>600</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>763</width>
<height>600</height>
</size>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QPushButton" name="pushButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>30</horstretch>
<verstretch>30</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::ClickFocus</enum>
</property>
<property name="text">
<string>OFF</string>
</property>
<property name="icon">
<iconset>
<normaloff>off.png</normaloff>
<normalon>on.jpg</normalon>off.png</iconset>
</property>
<property name="iconSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="Wifi">
<property name="text">
<string>Wifi Signal</string>
</property>
</widget>
</item>
<item>
<widget class="QProgressBar" name="wifiProgressBar">
<property name="value">
<number>95</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="BatteryLabel">
<property name="text">
<string>Battery</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QProgressBar" name="BatteryPB">
<property name="value">
<number>100</number>
</property>
<property name="textDirection">
<enum>QProgressBar::TopToBottom</enum>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<widget class="MainGlWidget" name="MainScreen" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>640</width>
<height>480</height>
</size>
</property>
<property name="cursor">
<cursorShape>OpenHandCursor</cursorShape>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<widget class="SideGlWidget" name="widget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>120</width>
<height>120</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50000</width>
<height>50000</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>MainGlWidget</class>
<extends>QWidget</extends>
<header>MainGlWidget.h</header>
<container>1</container>
<slots>
<slot>setXRotation(int)</slot>
<slot>setZRotation(int)</slot>
<slot>setYRotation(int)</slot>
</slots>
</customwidget>
<customwidget>
<class>SideGlWidget</class>
<extends>QWidget</extends>
<header>SideGlWidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

Why does enabling word wrap for a QLabel alter the layout?

So i have a small program i've made with Qt Designer, and for the most part, it's completely fine. But there is one niggling problem;
I have a QLabel, for which the text is sometimes too long, so i want to make the text wrap. This should be a simple task.
Here is what it looks like with no wordwrap
And this is fine. But when the text gets too long, it puts in a horrible scroll bar. I don't want this, so i enable wordwrap. But then this happens:
Which at first i thought was just Qt Designer being crap, so compiled and run hoping it would go away. Sometimes this happens, so i thought it was a reasonable assumption.
It wasn't.
Why the hell is this happening?!
EDIT: enabling word wrap manually in the widget initialiser also causes the same behaviour - so it's not caused by Qt Designer, it's an issue elsewhere. Any help would be greatly appreciated!
Here is the content of the 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>
QLabel in combination with word wrap and Layouts give some funny behaviour.
See https://bugreports.qt.io/browse/QTBUG-37673.
Why are you nesting your widgets (the QLabel and the QListWidget) into a QWidget?
That's why you are getting two scrollbars. One from the QListWidget, because it has more items than can be viewed. And one for the parent QWidget.
You should be using layouts.
This is what you have:
Should be something like this:

Resources