setFont() Applying Everything except Size Changes - qt

I am trying to apply Class-Based Font changes, and have found this information: Changing font size of all QLabel objects PyQt5
QFont font_label = QFont("MS Shell Dlg 2", 12, QFont::Normal);
QApplication::setFont(font_label, "QLabel");
The above code successfully applies everything except the Font Size, and calling font_label.setPointSize(x); does not change anything.
Project Details:
Using Qt 5.12.11 with CMake and MSVC
Creating .ui files with QT Designer
Besides implementing QDarkStlyeSheet I do nothing relevant with Style Sheets
No other Font alterations appear in my code
I have also discovered odd reproducible examples:
I thought it had to do with my QLabels being RichText, but changing them all to PlainText did not solve anything.
The only QLabel's that resize are default pointSize ones
My layouts do not seems to be imposing anything that would limit their size changes, and the above situations seems to support this.
This problem occurs when trying to change the font size in any direction.
UI File:
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MreApp</class>
<widget class="QMainWindow" name="MreApp">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1920</width>
<height>1050</height>
</rect>
</property>
<property name="windowTitle">
<string>MreApp</string>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<widget class="QWidget" name="Back">
<widget class="QLabel" name="label_1">
<property name="geometry">
<rect>
<x>490</x>
<y>660</y>
<width>95</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>8</pointsize>
</font>
</property>
<property name="text">
<string>I start size 8</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_4">
<property name="geometry">
<rect>
<x>690</x>
<y>80</y>
<width>481</width>
<height>131</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>Try Draggin in a new QLabel in QT Designer, it will listen to the code temporarily.</string>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>660</x>
<y>570</y>
<width>95</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>I start size 10</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>780</x>
<y>570</y>
<width>95</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>I start size 10</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_5">
<property name="geometry">
<rect>
<x>1190</x>
<y>570</y>
<width>371</width>
<height>16</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>(The Label Below is a fresh one, dragged in from QT Designer)</string>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>1270</x>
<y>690</y>
<width>201</width>
<height>61</height>
</rect>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</widget>
<action name="menu_new">
<property name="text">
<string>New</string>
</property>
</action>
<action name="menu_load">
<property name="text">
<string>Load</string>
</property>
</action>
<action name="menu_save">
<property name="text">
<string>Save</string>
</property>
</action>
<action name="menu_saveAs">
<property name="text">
<string>Save As</string>
</property>
</action>
<action name="menu_userManual">
<property name="text">
<string>User Manual</string>
</property>
</action>
</widget>
<resources/>
<connections/>
</ui>

You've set a fixed font size for the QLabels in the ui therefore when you change the application's global font size, it won't affect those.
<font>
<pointsize>10</pointsize>
</font>
Changing the application's font size sets a default size for the widgets. If you set the font size of one specific widget, it will overwrite the default one (this is what happened in your case).
If you want to change the font size, set the widget's font, like:
auto lbl = ui->label_2;
auto font = lbl->font();
font.setPointSize(2);
lbl->setFont(font);

Related

Qt Designer: how to remove empty space around QTableWidget

The Question is like said in the Title, how can i remove the Empty Space in the QTableWidget in the QT Designer?
Here is a screenshot of it:
More important is the white space below and not the whie spaces on the right!
the QTableWidget is inside a Vertical Layout and underneath the Layout is a Vertical Spacer
with these Propertys:
Here are the Vertical Layout Propertys:
It can be done with sizeAdjustPolicy, which is located in the QAbstractScrollArea section of the Property Editor in Qt Designer. When this is combined with a Minimum size-policy on the table (and possibly also hidden scrollbars), it should achieve what you want:
However, it should be noted that the size-adjust-policy doesn't seem to handle hidden table-headers properly (which looks like a bug).
Here's a demo designer ui file:
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Form</class>
<widget class="QWidget" name="Form">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>392</width>
<height>199</height>
</rect>
</property>
<property name="windowTitle">
<string>Test</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Table</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QTableWidget" name="tableWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::AdjustToContents</enum>
</property>
<row>
<property name="text">
<string>1</string>
</property>
</row>
<row>
<property name="text">
<string>2</string>
</property>
</row>
<column>
<property name="text">
<string>A</string>
</property>
</column>
<column>
<property name="text">
<string>B</string>
</property>
</column>
<column>
<property name="text">
<string>C</string>
</property>
</column>
</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>
</widget>
<resources/>
<connections/>
</ui>

Change the thickness of HLine/VLine in Qt Designer

When I am trying to develop a simple UI, to make a visible separation between widgets I decided to use lines. I could use them, but when I try to change the thickness of them it didn't work. And also the lines drawn are incomplete. I changed the lineWidth property to change the thickness. This is the demonstration of how I did it.
Has someone got any experience about this? Can someone show me what I am doing wrong, and how to do it properly?
[NB: the solution given below assumes the default Fusion widget-style is being used. Some other custom styles may impose their own settings, which could very likely produce different results]
There are two separate issues here:
Firstly, to get the desired thickness, you must adjust the following properties of the line:
set the frameShadow to Sunken or Raised
set the lineWidth to zero (this is needed so as to get the exact desired thickness, since it would otherwise increase the total value)
set the midLineWidth to the desired thickness (e.g. 10)
set the minimumHeight (or minimumWidth, for vertical lines) to the same value as above
[optional] set the Mid role in the palette to an appropriate colour
Secondly, to join horizontal and vertical lines so they form a T-junction, you must set the vertcal and/or horizontal spacing to zero for the layouts containing the relevant lines, and then set the stylesheet margins of the neighbouring widgets to restore the spacing wherever needed. To illustrate this, I have added below a simple Qt Designer example. This sets the vertical spacing of the main grid-layout to zero, and also sets the margin-bottom of the top widget, and the margin-top of the two bottom widgets to the default spacing of the layout:
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Form</class>
<widget class="QWidget" name="Form">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="verticalSpacing">
<number>0</number>
</property>
<item row="2" column="1">
<widget class="Line" name="line_2">
<property name="minimumSize">
<size>
<width>10</width>
<height>0</height>
</size>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<property name="midLineWidth">
<number>10</number>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item row="1" column="0" colspan="3">
<widget class="Line" name="line">
<property name="minimumSize">
<size>
<width>0</width>
<height>10</height>
</size>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<property name="midLineWidth">
<number>10</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="styleSheet">
<string notr="true">background: white; margin-top: 6px</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="label_3">
<property name="styleSheet">
<string notr="true">background: white; margin-top: 6px</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
</widget>
</item>
<item row="0" column="0" colspan="3">
<widget class="QLabel" name="label">
<property name="styleSheet">
<string notr="true">background: white; margin-bottom: 6px</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

Open .ui file from Linux on Windows

My colleague created a C++ Qt Project on Linux and I "transposed" it on Windows. Now, I am a functional GUI but I don't know why, when I open the .ui file with QtDesigner, the file is empty, all widgets disappeared.
Any idea how to get back my widgets or is it only because the file was created on QtDesigner on Linux ?
Here is a part of the ui file opened on Windows with a text editor:
<?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>874</width>
<height>497</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QTabWidget" name="tabWidget">
<property name="geometry">
<rect>
<x>20</x>
<y>110</y>
<width>541</width>
<height>331</height>
</rect>
</property>
<property name="maximumSize">
<size>
<width>860</width>
<height>700</height>
</size>
</property>
<property name="currentIndex">
<number>1</number>
</property>
<widget class="QWidget" name="buildMotionTab_3">
<attribute name="title">
<string>Tab 1</string>
</attribute>
<widget class="QFrame" name="centralFrame_3">
<property name="geometry">
<rect>
<x>-10</x>
<y>0</y>
<width>860</width>
<height>851</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>860</width>
<height>851</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>810</width>
<height>851</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<widget class="QFrame" name="motorFrameP_3">
<property name="geometry">
<rect>
<x>260</x>
<y>10</y>
<width>281</width>
<height>280</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>250</width>
<height>280</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>300</width>
<height>280</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<widget class="QSpinBox" name="LineDist">
<property name="geometry">
<rect>
<x>190</x>
<y>150</y>
<width>81</width>
<height>32</height>
</rect>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>470</number>
</property>
<property name="singleStep">
<number>1</number>
</property>
<property name="value">
<number>50</number>
</property>
</widget>
[...]
<widget class="QPushButton" name="StandDownButton">
<property name="geometry">
<rect>
<x>20</x>
<y>30</y>
<width>101</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>StandDown</string>
</property>
</widget>
<widget class="QPushButton" name="Homing1Button">
<property name="geometry">
<rect>
<x>120</x>
<y>70</y>
<width>101</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>Homing X</string>
</property>
</widget>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>874</width>
<height>25</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>
Looks like some thing went wrong in transporting the file (I can't say, but could be copy was done in binary mode? or some lines were not expanded in case you copied and pasted the text ..)
The ui xml you shared is broken at line 127 where it shows [...] which is not valid, in place of this it should show closing xml tags for </widget> , I think 4 closing tags </widget> are missing, then it should be ok.

PyQt 5 : How to save contents of the line edit into a txt file ? How to load the contents of a text file, to autofill the line edit?

I am trying to create a configuration tool that helps link attributes of one tool with another. I have created the config window using PyQt5.
I want to:
Save the value of the line edit, into a text file. ---> when clicked on Save
Load the values of a text file , into the line edit ---> when clicked on Load
This is how the UI looks
The UI of the config file- Config.ui
I have tried the functions getSaveFileName , getOpenFileName but all i get is the path on the cmd, and no actual file is saved or opened.
what should be done in order to save the file contents ?
Please be kind with your answers :)
This is how the programming GUI looks like :
# Config program using PyQt5
import sys
from PyQt5 import QtCore, QtGui, uic, QtWidgets
from PyQt5.QtWidgets import QFileDialog
form_class = uic.loadUiType("Config.ui")[0] # Load the UI
class Mapper(QtWidgets.QMainWindow, form_class):
def __init__(self, parent=None):
QtWidgets.QMainWindow.__init__(self, parent)
self.setupUi(self)
# Bind the event handlers to the buttons
self.saveButton.clicked.connect(self.saveFileDialog)
self.loadButton.clicked.connect(self.loadFileDialog)
def saveFileDialog(self):
options = QFileDialog.Options()
options |= QFileDialog.DontUseNativeDialog
fileName, _ = QFileDialog.getSaveFileName(self, "QFileDialog.getSaveFileName()", "",
"All Files (*);;Text Files (*.txt)", options=options)
if fileName:
print(fileName)
def loadFileDialog(self):
options = QFileDialog.Options()
options |= QFileDialog.DontUseNativeDialog
files, _ = QFileDialog.getOpenFileNames(self, "QFileDialog.getOpenFileNames()", "",
"All Files (*);;Python Files (*.py)", options=options)
if files:
print(files)
app = QtWidgets.QApplication(sys.argv)
myWindow = Mapper()
myWindow.show()
app.exec_()
This is how the Config.ui looks :
<?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>545</width>
<height>728</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Ignored">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="windowTitle">
<string>Configuration Window</string>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QFrame" name="mainFrame">
<property name="geometry">
<rect>
<x>20</x>
<y>-10</y>
<width>911</width>
<height>721</height>
</rect>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<widget class="QGroupBox" name="mapGroupBox">
<property name="geometry">
<rect>
<x>30</x>
<y>20</y>
<width>481</width>
<height>581</height>
</rect>
</property>
<property name="title">
<string>MAPPING ATTRIBUTES</string>
</property>
<widget class="QGroupBox" name="ecuGroupBox">
<property name="geometry">
<rect>
<x>20</x>
<y>30</y>
<width>211</width>
<height>531</height>
</rect>
</property>
<property name="title">
<string>ECU TEST Attributes</string>
</property>
<widget class="QLabel" name="ModuleName">
<property name="geometry">
<rect>
<x>10</x>
<y>30</y>
<width>111</width>
<height>16</height>
</rect>
</property>
<property name="font">
<font>
<family>Nirmala UI</family>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>ModuleName</string>
</property>
</widget>
<widget class="QLabel" name="aObjectType">
<property name="geometry">
<rect>
<x>10</x>
<y>60</y>
<width>81</width>
<height>16</height>
</rect>
</property>
<property name="font">
<font>
<family>Nirmala UI</family>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>aObjectType</string>
</property>
</widget>
<widget class="QLabel" name="TestDescription">
<property name="geometry">
<rect>
<x>10</x>
<y>90</y>
<width>101</width>
<height>16</height>
</rect>
</property>
<property name="font">
<font>
<family>Nirmala UI</family>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>TestDescription</string>
</property>
</widget>
<widget class="QLabel" name="Preconditions">
<property name="geometry">
<rect>
<x>10</x>
<y>390</y>
<width>91</width>
<height>16</height>
</rect>
</property>
<property name="font">
<font>
<family>Nirmala UI</family>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Preconditions</string>
</property>
</widget>
<widget class="QLabel" name="Testcase_ID">
<property name="geometry">
<rect>
<x>10</x>
<y>210</y>
<width>91</width>
<height>16</height>
</rect>
</property>
<property name="font">
<font>
<family>Nirmala UI</family>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Testcase_ID</string>
</property>
</widget>
<widget class="QLabel" name="function">
<property name="geometry">
<rect>
<x>10</x>
<y>330</y>
<width>81</width>
<height>16</height>
</rect>
</property>
<property name="font">
<font>
<family>Nirmala UI</family>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Function</string>
</property>
</widget>
<widget class="QLabel" name="Priority">
<property name="geometry">
<rect>
<x>10</x>
<y>300</y>
<width>55</width>
<height>16</height>
</rect>
</property>
<property name="font">
<font>
<family>Nirmala UI</family>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Priority</string>
</property>
</widget>
<widget class="QLabel" name="TestName">
<property name="geometry">
<rect>
<x>10</x>
<y>240</y>
<width>71</width>
<height>16</height>
</rect>
</property>
<property name="font">
<font>
<family>Nirmala UI</family>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>TestName</string>
</property>
</widget>
<widget class="QLabel" name="TestFocus">
<property name="geometry">
<rect>
<x>10</x>
<y>150</y>
<width>81</width>
<height>16</height>
</rect>
</property>
<property name="font">
<font>
<family>Nirmala UI</family>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>TestFocus</string>
</property>
</widget>
<widget class="QLabel" name="Action">
<property name="geometry">
<rect>
<x>10</x>
<y>420</y>
<width>61</width>
<height>16</height>
</rect>
</property>
<property name="font">
<font>
<family>Nirmala UI</family>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Action</string>
</property>
</widget>
<widget class="QLabel" name="CreatedBy">
<property name="geometry">
<rect>
<x>10</x>
<y>480</y>
<width>81</width>
<height>16</height>
</rect>
</property>
<property name="font">
<font>
<family>Nirmala UI</family>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>CreatedBy</string>
</property>
</widget>
<widget class="QLabel" name="TestLocation">
<property name="geometry">
<rect>
<x>10</x>
<y>360</y>
<width>101</width>
<height>16</height>
</rect>
</property>
<property name="font">
<font>
<family>Nirmala UI</family>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>TestLocation</string>
</property>
</widget>
<widget class="QLabel" name="Status">
<property name="geometry">
<rect>
<x>10</x>
<y>270</y>
<width>55</width>
<height>16</height>
</rect>
</property>
<property name="font">
<font>
<family>Nirmala UI</family>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Status</string>
</property>
</widget>
<widget class="QLabel" name="Req_ID">
<property name="geometry">
<rect>
<x>10</x>
<y>180</y>
<width>55</width>
<height>16</height>
</rect>
</property>
<property name="font">
<font>
<family>Nirmala UI</family>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Req_ID</string>
</property>
</widget>
<widget class="QLabel" name="TestPictureName">
<property name="geometry">
<rect>
<x>10</x>
<y>120</y>
<width>111</width>
<height>16</height>
</rect>
</property>
<property name="font">
<font>
<family>Nirmala UI</family>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>TestPictureName</string>
</property>
</widget>
<widget class="QLabel" name="ExpectedResult">
<property name="geometry">
<rect>
<x>10</x>
<y>450</y>
<width>111</width>
<height>16</height>
</rect>
</property>
<property name="font">
<font>
<family>Nirmala UI</family>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>ExpectedResult</string>
</property>
</widget>
</widget>
<widget class="QGroupBox" name="doorsGroupBox">
<property name="geometry">
<rect>
<x>250</x>
<y>29</y>
<width>211</width>
<height>531</height>
</rect>
</property>
<property name="title">
<string>DOORS Attributes</string>
</property>
<widget class="QLineEdit" name="lineEdit">
<property name="geometry">
<rect>
<x>10</x>
<y>30</y>
<width>181</width>
<height>22</height>
</rect>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_2">
<property name="geometry">
<rect>
<x>10</x>
<y>60</y>
<width>181</width>
<height>22</height>
</rect>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_3">
<property name="geometry">
<rect>
<x>10</x>
<y>90</y>
<width>181</width>
<height>22</height>
</rect>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_4">
<property name="geometry">
<rect>
<x>10</x>
<y>120</y>
<width>181</width>
<height>22</height>
</rect>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_5">
<property name="geometry">
<rect>
<x>10</x>
<y>150</y>
<width>181</width>
<height>22</height>
</rect>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_6">
<property name="geometry">
<rect>
<x>10</x>
<y>180</y>
<width>181</width>
<height>22</height>
</rect>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_7">
<property name="geometry">
<rect>
<x>10</x>
<y>210</y>
<width>181</width>
<height>22</height>
</rect>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_8">
<property name="geometry">
<rect>
<x>10</x>
<y>240</y>
<width>181</width>
<height>22</height>
</rect>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_9">
<property name="geometry">
<rect>
<x>10</x>
<y>270</y>
<width>181</width>
<height>22</height>
</rect>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_10">
<property name="geometry">
<rect>
<x>10</x>
<y>300</y>
<width>181</width>
<height>22</height>
</rect>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_11">
<property name="geometry">
<rect>
<x>10</x>
<y>330</y>
<width>181</width>
<height>22</height>
</rect>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_12">
<property name="geometry">
<rect>
<x>10</x>
<y>360</y>
<width>181</width>
<height>22</height>
</rect>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_13">
<property name="geometry">
<rect>
<x>10</x>
<y>390</y>
<width>181</width>
<height>22</height>
</rect>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_14">
<property name="geometry">
<rect>
<x>10</x>
<y>420</y>
<width>181</width>
<height>22</height>
</rect>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_15">
<property name="geometry">
<rect>
<x>10</x>
<y>450</y>
<width>181</width>
<height>22</height>
</rect>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_16">
<property name="geometry">
<rect>
<x>10</x>
<y>480</y>
<width>181</width>
<height>22</height>
</rect>
</property>
</widget>
</widget>
</widget>
<widget class="QPushButton" name="saveButton">
<property name="geometry">
<rect>
<x>30</x>
<y>630</y>
<width>93</width>
<height>28</height>
</rect>
</property>
<property name="toolTip">
<string>Save The Current Configuration</string>
</property>
<property name="toolTipDuration">
<number>1</number>
</property>
<property name="text">
<string>Save</string>
</property>
</widget>
<widget class="QPushButton" name="loadButton">
<property name="geometry">
<rect>
<x>140</x>
<y>630</y>
<width>93</width>
<height>28</height>
</rect>
</property>
<property name="toolTip">
<string>Load Existing Configuration</string>
</property>
<property name="toolTipDuration">
<number>1</number>
</property>
<property name="text">
<string>Load</string>
</property>
</widget>
</widget>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>545</width>
<height>26</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<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