Make Window start as compact as possible?
-
I have the following code of a Main_Window. Now, my problem is that when I preview the window it starts not in the minimum size (meaning I can resize it, make it even smaller.) How can I make it start as compact as possible?
<?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>930</width> <height>755</height> </rect> </property> <property name="windowTitle"> <string>MainWindow</string> </property> <widget class="QWidget" name="centralwidget"> <layout class="QGridLayout" name="gridLayout_2"> <item row="0" column="0"> <layout class="QGridLayout" name="gridLayout"> <item row="0" column="0"> <widget class="QTabWidget" name="tabWidget"> <property name="currentIndex"> <number>0</number> </property> <widget class="QWidget" name="tab"> <attribute name="title"> <string>Tab 1</string> </attribute> <layout class="QVBoxLayout" name="verticalLayout_2"> <item> <layout class="QVBoxLayout" name="verticalLayout_1"> <property name="spacing"> <number>3</number> </property> <item> <layout class="QHBoxLayout" name="horizontalLayout_1"> <item> <layout class="QVBoxLayout" name="verticalLayout_3" stretch="0,0,0,0,0,0,0,0"> <property name="spacing"> <number>2</number> </property> <property name="sizeConstraint"> <enum>QLayout::SetMinimumSize</enum> </property> <item> <spacer name="verticalSpacer_1"> <property name="orientation"> <enum>Qt::Vertical</enum> </property> <property name="sizeHint" stdset="0"> <size> <width>20</width> <height>20</height> </size> </property> </spacer> </item> <item> <layout class="QHBoxLayout" name="horizontalLayout_3"> <item> <spacer name="horizontalSpacer_1"> <property name="orientation"> <enum>Qt::Horizontal</enum> </property> <property name="sizeHint" stdset="0"> <size> <width>20</width> <height>20</height> </size> </property> </spacer> </item> <item alignment="Qt::Alignb3"> <widget class="QPushButton" name="b1_Button"> <property name="text"> <string>b1</string> </property> </widget> </item> <item> <widget class="QPushButton" name="b2_Button"> <property name="text"> <string>b2</string> </property> </widget> </item> <item> <spacer name="horizontalSpacer_2"> <property name="orientation"> <enum>Qt::Horizontal</enum> </property> <property name="sizeHint" stdset="0"> <size> <width>20</width> <height>20</height> </size> </property> </spacer> </item> </layout> </item> <item alignment="Qt::AlignHCenter"> <widget class="QPushButton" name="b5_Button"> <property name="text"> <string>b5</string> </property> </widget> </item> <item> <layout class="QHBoxLayout" name="horizontalLayout_4"> <item> <spacer name="horizontalSpacer_3"> <property name="orientation"> <enum>Qt::Horizontal</enum> </property> <property name="sizeHint" stdset="0"> <size> <width>20</width> <height>20</height> </size> </property> </spacer> </item> <item> <widget class="QPushButton" name="b3_Button"> <property name="text"> <string>b3</string> </property> </widget> </item> <item> <widget class="QPushButton" name="b4_Button"> <property name="text"> <string>b4</string> </property> </widget> </item> <item> <spacer name="horizontalSpacer_4"> <property name="orientation"> <enum>Qt::Horizontal</enum> </property> <property name="sizeHint" stdset="0"> <size> <width>20</width> <height>20</height> </size> </property> </spacer> </item> </layout> </item> <item alignment="Qt::AlignHCenter"> <widget class="QPushButton" name="b6_Button"> <property name="text"> <string>b6</string> </property> </widget> </item> <item> <layout class="QHBoxLayout" name="horizontalLayout_5"> <property name="spacing"> <number>1</number> </property> <item> <spacer name="horizontalSpacer_5"> <property name="orientation"> <enum>Qt::Horizontal</enum> </property> <property name="sizeHint" stdset="0"> <size> <width>20</width> <height>20</height> </size> </property> </spacer> </item> <item> <widget class="QComboBox" name="ch1_2_comboBox"> <property name="minimumSize"> <size> <width>70</width> <height>20</height> </size> </property> <property name="maximumSize"> <size> <width>100</width> <height>30</height> </size> </property> <item> <property name="text"> <string>ch1</string> </property> </item> <item> <property name="text"> <string>ch2</string> </property> </item> </widget> </item> <item alignment="Qt::Alignb3|Qt::AlignVCenter"> <widget class="QLineEdit" name="op1_lineEdit"> <property name="enabled"> <bool>true</bool> </property> <property name="minimumSize"> <size> <width>22</width> <height>22</height> </size> </property> <property name="maximumSize"> <size> <width>30</width> <height>30</height> </size> </property> <property name="inputMask"> <string/> </property> <property name="text"> <string>5</string> </property> <property name="maxLength"> <number>3</number> </property> <property name="frame"> <bool>true</bool> </property> <property name="alignment"> <set>Qt::AlignCenter</set> </property> </widget> </item> <item> <widget class="QLabel" name="op2_label"> <property name="minimumSize"> <size> <width>70</width> <height>20</height> </size> </property> <property name="maximumSize"> <size> <width>100</width> <height>30</height> </size> </property> <property name="styleSheet"> <string notr="true">color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); </string> </property> <property name="text"> <string>Velocity</string> </property> <property name="alignment"> <set>Qt::AlignCenter</set> </property> </widget> </item> <item> <widget class="QLineEdit" name="op2_lineEdit"> <property name="minimumSize"> <size> <width>22</width> <height>22</height> </size> </property> <property name="maximumSize"> <size> <width>30</width> <height>30</height> </size> </property> <property name="inputMask"> <string/> </property> <property name="text"> <string>5</string> </property> <property name="maxLength"> <number>3</number> </property> <property name="alignment"> <set>Qt::AlignCenter</set> </property> </widget> </item> <item> <spacer name="horizontalSpacer_6"> <property name="orientation"> <enum>Qt::Horizontal</enum> </property> <property name="sizeHint" stdset="0"> <size> <width>20</width> <height>20</height> </size> </property> </spacer> </item> </layout> </item> <item alignment="Qt::AlignHCenter|Qt::AlignVCenter"> <widget class="QPushButton" name="b7_Button"> <property name="text"> <string>b7</string> </property> </widget> </item> <item> <spacer name="verticalSpacer_2"> <property name="orientation"> <enum>Qt::Vertical</enum> </property> <property name="sizeHint" stdset="0"> <size> <width>20</width> <height>20</height> </size> </property> </spacer> </item> </layout> </item> <item> <widget class="Line" name="line"> <property name="orientation"> <enum>Qt::Vertical</enum> </property> </widget> </item> <item> <layout class="QHBoxLayout" name="horizontalLayout_2"> <item> <layout class="QVBoxLayout" name="verticalLayout_4"> <item> <widget class="QLabel" name="video_label"> <property name="minimumSize"> <size> <width>640</width> <height>480</height> </size> </property> <property name="maximumSize"> <size> <width>640</width> <height>480</height> </size> </property> <property name="baseSize"> <size> <width>640</width> <height>480</height> </size> </property> <property name="text"> <string/> </property> </widget> </item> <item> <layout class="QHBoxLayout" name="horizontalLayout_6"> <item> <layout class="QVBoxLayout" name="verticalLayout_5"> <property name="spacing"> <number>0</number> </property> <item> <widget class="QCheckBox" name="ch1_checkBox"> <property name="enabled"> <bool>true</bool> </property> <property name="text"> <string>Check this</string> </property> <property name="checked"> <bool>true</bool> </property> <property name="tristate"> <bool>false</bool> </property> </widget> </item> <item> <layout class="QHBoxLayout" name="horizontalLayout_7"> <property name="spacing"> <number>0</number> </property> <item alignment="Qt::Alignb3"> <widget class="QCheckBox" name="trace_checkBox"> <property name="enabled"> <bool>true</bool> </property> <property name="text"> <string>Trace this</string> </property> <property name="checked"> <bool>true</bool> </property> <property name="tristate"> <bool>false</bool> </property> </widget> </item> <item> <widget class="QToolButton" name="hsvPicker_toolButton"> <property name="text"> <string>...</string> </property> </widget> </item> </layout> </item> </layout> </item> <item> <spacer name="horizontalSpacer_7"> <property name="orientation"> <enum>Qt::Horizontal</enum> </property> <property name="sizeHint" stdset="0"> <size> <width>20</width> <height>20</height> </size> </property> </spacer> </item> <item> <widget class="QPushButton" name="start_Button"> <property name="text"> <string>Start</string> </property> </widget> </item> <item> <widget class="QPushButton" name="stop_Button"> <property name="text"> <string>Stop</string> </property> </widget> </item> <item> <spacer name="horizontalSpacer_8"> <property name="orientation"> <enum>Qt::Horizontal</enum> </property> <property name="sizeHint" stdset="0"> <size> <width>20</width> <height>20</height> </size> </property> </spacer> </item> <item> <widget class="QRadioButton" name="video_radioButton"> <property name="styleSheet"> <string notr="true">color: rgb(255, 255, 255);</string> </property> <property name="text"> <string>Video</string> </property> <property name="checked"> <bool>true</bool> </property> </widget> </item> <item> <widget class="QRadioButton" name="voice_radioButton"> <property name="styleSheet"> <string notr="true">color: rgb(255, 255, 255);</string> </property> <property name="text"> <string>Voice</string> </property> <property name="checked"> <bool>false</bool> </property> <property name="autoExclusive"> <bool>true</bool> </property> </widget> </item> <item> <widget class="QRadioButton" name="both_radioButton"> <property name="autoFillBackground"> <bool>false</bool> </property> <property name="styleSheet"> <string notr="true">color: rgb(255, 255, 255);</string> </property> <property name="text"> <string>Both</string> </property> </widget> </item> </layout> </item> </layout> </item> </layout> </item> </layout> </item> <item> <layout class="QHBoxLayout" name="horizontalLayout_8"> <item> <layout class="QVBoxLayout" name="verticalLayout_6"> <property name="spacing"> <number>1</number> </property> <item> <spacer name="verticalSpacer_3"> <property name="orientation"> <enum>Qt::Vertical</enum> </property> <property name="sizeHint" stdset="0"> <size> <width>20</width> <height>20</height> </size> </property> </spacer> </item> <item> <widget class="QPushButton" name="b8_Button"> <property name="text"> <string>b8</string> </property> </widget> </item> <item alignment="Qt::Alignb3|Qt::AlignVCenter"> <widget class="QLabel" name="b8_label"> <property name="text"> <string>Status: b8Status</string> </property> <property name="alignment"> <set>Qt::AlignCenter</set> </property> </widget> </item> </layout> </item> <item> <layout class="QVBoxLayout" name="verticalLayout_7"> <property name="spacing"> <number>1</number> </property> <property name="sizeConstraint"> <enum>QLayout::SetMinimumSize</enum> </property> <item> <spacer name="verticalSpacer_4"> <property name="orientation"> <enum>Qt::Vertical</enum> </property> <property name="sizeHint" stdset="0"> <size> <width>20</width> <height>20</height> </size> </property> </spacer> </item> <item alignment="Qt::Alignb3|Qt::AlignVCenter"> <widget class="QLabel" name="output_label"> <property name="text"> <string>Console Output</string> </property> </widget> </item> <item> <widget class="QTextBrowser" name="output_textBrowser"> <property name="minimumSize"> <size> <width>700</width> <height>60</height> </size> </property> <property name="maximumSize"> <size> <width>1300</width> <height>300</height> </size> </property> </widget> </item> </layout> </item> </layout> </item> </layout> </item> </layout> </widget> <widget class="QWidget" name="tab_2"> <attribute name="title"> <string>Tab 2</string> </attribute> <layout class="QGridLayout" name="gridLayout_5"/> </widget> </widget> </item> </layout> </item> </layout> </widget> <widget class="QMenuBar" name="menubar"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>930</width> <height>26</height> </rect> </property> <widget class="QMenu" name="menuFile"> <property name="title"> <string>File</string> </property> </widget> <addaction name="menuFile"/> </widget> <widget class="QStatusBar" name="statusbar"/> </widget> <resources/> <connections/> </ui>
-
I omitted that (replaced those two values with 0) and I still get the same results. So If I enlarge the window in the designer it shows up in the preview enlarged (exactly how I made it in the designer.) When I make it as small as possible in the designer when I preview it I can make it even smaller. I want it to be the smallest possible!
-
@PascP said in Make Window start as compact as possible?:
I omitted that (replaced those two values with 0) and I still get the same results.
And you went through your QML file and equally got rid of other large, explicit sizes there like for your
QMenuBar
, didn't you?Or tried setting them all to like 1x1 and see whether Qt auto-sizes everything to smallest?
-
Ok, So I converted it in python. I tried to run but it gave an AttributeError: type object 'Qt' has no attribute 'Alignb3' error. I changed all the instances of Alignb3 to AlignHCenter and it as displayed as it should be in minimum size. But what is Alignb3? and why it converts AlignHCenter to b3 automatically?