Unsolved QLabel inserts (automatic) a blank line
-
I have written a post on stackoverflow. If anyone knows, I would be very grateful for a description!
https://stackoverflow.com/questions/54178206/qlabel-inserts-automatic-a-blank-line
-
-
Qt Creator 4.6.2
Based on Qt 5.11.1 (Clang 8.0 (Apple), 64 bit)
Built on Jun 18 2018 11:51:56
From revision 1ddfb443b6iOS 12.1.2
Hope it helps!
-
Perhaps your labels are for some reason aligned at bottom. Use setAlignment() to try to fix.
-
@mvuori No, I set the alignment extra to top. It is an additional line break at begin of my text. But these line break is inserted by QLabel!
-
Hi,
Can you provide a minimal compilable example that reproduces that behaviour ?
-
@peter-70 said in QLabel inserts (automatic) a blank line:
Qt Creator 4.6.2
Based on Qt 5.11.1 (Clang 8.0 (Apple), 64 bit)Just a note for the future: this is NOT necessarily Qt version you're using. This is the Qt version which was used to compile QtCreator. To find out which Qt version you're using go to your Kit configuration and see there.
-
EDIT:
I noticed something (probably) quite important. If I build my UI so that it is not embraced by a vertical layout, then the QLabels will be displayed correctly. But if I build them up so that all elements are spanned by a vertical layout, then there is the rendering problem (as described above). This extremely strange behavior is comprehensible and man can be switched back and forth: with QVBoxLayout-> display error, without QVBoxLayout-> no errors, and so on ...
Here you can see the UI-Code without vertical layout around the UI-elements:
[?xml version="1.0" encoding="UTF-8"?] [ui version="4.0"] [class]PrjNameMeldung1_5[/class] [widget class="QMainWindow" name="PrjNameMeldung1_5"] [property name="geometry"] [rect] [x]0[/x] [y]0[/y] [width]375[/width] [height]444[/height] [/rect] [/property] [property name="windowTitle"] [string]MainWindow[/string] [/property] [widget class="QWidget" name="centralwidget"] [widget class="QWidget" name="gridLayoutWidget"] [property name="geometry"] [rect] [x]9[/x] [y]25[/y] [width]361[/width] [height]401[/height] [/rect] [/property] [layout class="QGridLayout" name="gridLayout"] [item row="3" column="0"] [widget class="PrjListControl" name="listWidget"] [property name="sizePolicy"] [sizepolicy hsizetype="Expanding" vsizetype="Expanding"] [horstretch]0[/horstretch] [verstretch]0[/verstretch] [/sizepolicy] [/property] [/widget] [/item] [item row="1" column="0"] [widget class="QLabel" name="m_editTPAggregat"] [property name="text"] [string]TPAggregat[/string] [/property] [/widget] [/item] [item row="2" column="0"] [widget class="QLabel" name="m_labelAuswahl"] [property name="text"] [string]Baugruppe[/string] [/property] [property name="alignment"] [set]Qt::AlignCenter[/set] [/property] [/widget] [/item] [item row="0" column="0"] [widget class="QLabel" name="m_editTP"] [property name="text"] [string]TP[/string] [/property] [property name="alignment"] [set]Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop[/set] [/property] [/widget] [/item] [/layout] [/widget] [widget class="PrjToolBar" name="m_groupMenuBar" native="true"] [property name="geometry"] [rect] [x]9[/x] [y]425[/y] [width]357[/width] [height]16[/height] [/rect] [/property] [property name="sizePolicy"] [sizepolicy hsizetype="Preferred" vsizetype="Fixed"] [horstretch]0[/horstretch] [verstretch]0[/verstretch] [/sizepolicy] [/property] [property name="minimumSize"] [size] [width]0[/width] [height]10[/height] [/size] [/property] [/widget] [widget class="PrjNavigationBar" name="m_groupWindowTitle" native="true"] [property name="geometry"] [rect] [x]9[/x] [y]9[/y] [width]357[/width] [height]16[/height] [/rect] [/property] [property name="sizePolicy"] [sizepolicy hsizetype="Preferred" vsizetype="Fixed"] [horstretch]0[/horstretch] [verstretch]0[/verstretch] [/sizepolicy] [/property] [property name="minimumSize"] [size] [width]0[/width] [height]10[/height] [/size] [/property] [/widget] [/widget] [/widget] [customwidgets] [customwidget] [class]PrjToolBar[/class] [extends]QWidget[/extends] [header location="global"]controls/Prjtoolbar.h[/header] [container]1[/container] [/customwidget] [customwidget] [class]PrjNavigationBar[/class] [extends]QWidget[/extends] [header location="global"]controls/Prjnavigationbar.h[/header] [container]1[/container] [/customwidget] [customwidget] [class]PrjListControl[/class] [extends]QListWidget[/extends] [header location="global"]controls/Prjlistcontrol.h[/header] [/customwidget] [/customwidgets] [resources/] [connections/] [/ui]
And here you can see the UI-Code with vertical layout around the UI-elements:
[?xml version="1.0" encoding="UTF-8"?] [ui version="4.0"] [class]PrjNameMeldung1_5[/class] [widget class="QMainWindow" name="PrjNameMeldung1_5"] [property name="geometry"] [rect] [x]0[/x] [y]0[/y] [width]375[/width] [height]444[/height] [/rect] [/property] [property name="windowTitle"] [string]MainWindow[/string] [/property] [widget class="QWidget" name="centralwidget"] [layout class="QVBoxLayout" name="verticalLayout"] [item] [widget class="PrjNavigationBar" name="m_groupWindowTitle" native="true"] [property name="sizePolicy"] [sizepolicy hsizetype="Preferred" vsizetype="Fixed"] [horstretch]0[/horstretch] [verstretch]0[/verstretch] [/sizepolicy] [/property] [property name="minimumSize"] [size] [width]0[/width] [height]10[/height] [/size] [/property] [/widget] [/item] [item] [layout class="QGridLayout" name="gridLayout"] [item row="3" column="0"] [widget class="PrjListControl" name="listWidget"] [property name="sizePolicy"] [sizepolicy hsizetype="Expanding" vsizetype="Expanding"] [horstretch]0[/horstretch] [verstretch]0[/verstretch] [/sizepolicy] [/property] [/widget] [/item] [item row="1" column="0"] [widget class="QLabel" name="m_editTPAggregat"] [property name="text"] [string]TPAggregat[/string] [/property] [/widget] [/item] [item row="2" column="0"] [widget class="QLabel" name="m_labelAuswahl"] [property name="text"] [string]Baugruppe[/string] [/property] [property name="alignment"] [set]Qt::AlignCenter[/set] [/property] [/widget] [/item] [item row="0" column="0"] [widget class="QLabel" name="m_editTP"] [property name="text"] [string]TP[/string] [/property] [property name="alignment"] [set]Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop[/set] [/property] [/widget] [/item] [/layout] [/item] [item] [widget class="PrjToolBar" name="m_groupMenuBar" native="true"] [property name="sizePolicy"] [sizepolicy hsizetype="Preferred" vsizetype="Fixed"] [horstretch]0[/horstretch] [verstretch]0[/verstretch] [/sizepolicy] [/property] [property name="minimumSize"] [size] [width]0[/width] [height]10[/height] [/size] [/property] [/widget] [/item] [/layout] [/widget] [/widget] [customwidgets] [customwidget] [class]PrjToolBar[/class] [extends]QWidget[/extends] [header location="global"]controls/Prjtoolbar.h[/header] [container]1[/container] [/customwidget] [customwidget] [class]PrjNavigationBar[/class] [extends]QWidget[/extends] [header location="global"]controls/Prjnavigationbar.h[/header] [container]1[/container] [/customwidget] [customwidget] [class]PrjListControl[/class] [extends]QListWidget[/extends] [header location="global"]controls/Prjlistcontrol.h[/header] [/customwidget] [/customwidgets] [resources/] [connections/] [/ui]