Anonymous1245 Asked:2024-09-27 01:55:23 +0000 UTC2024-09-27 01:55:23 +0000 UTC 2024-09-27 01:55:23 +0000 UTC 如何确保按钮始终位于顶角? 772 我正在尝试这样做,但我仍然不明白如何做?我需要应用程序能够更改其大小,但同时所有内容都保持在原来的位置,而不是相对于整个窗口。 Layout没有完全按照需要做的事情 我试图确保按钮在那里并且始终保持在那里,无论窗口大小如何变化。 但布局不是那么......不合适。 python 1 个回答 Voted Best Answer S. Nick 2024-09-27T02:31:59Z2024-09-27T02:31:59Z 你没有仔细看我问你的内容。 试试这个: q1594978.ui: <?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>420</width> <height>364</height> </rect> </property> <property name="windowTitle"> <string>MainWindow</string> </property> <widget class="QWidget" name="centralwidget"> <layout class="QHBoxLayout" name="horizontalLayout"> <item> <layout class="QGridLayout" name="gridLayout"> <item row="1" column="0" colspan="3"> <widget class="QFrame" name="frame"> <property name="frameShape"> <enum>QFrame::StyledPanel</enum> </property> <property name="frameShadow"> <enum>QFrame::Raised</enum> </property> </widget> </item> <item row="0" column="0"> <widget class="QPushButton" name="pushButton"> <property name="minimumSize"> <size> <width>50</width> <height>50</height> </size> </property> <property name="maximumSize"> <size> <width>50</width> <height>50</height> </size> </property> <property name="text"> <string>byn1</string> </property> </widget> </item> <item row="0" column="2"> <widget class="QPushButton" name="pushButton_2"> <property name="minimumSize"> <size> <width>50</width> <height>50</height> </size> </property> <property name="maximumSize"> <size> <width>50</width> <height>50</height> </size> </property> <property name="text"> <string>btn2</string> </property> </widget> </item> <item row="0" column="1"> <widget class="QLabel" name="label"> <property name="text"> <string> </string> </property> </widget> </item> </layout> </item> </layout> </widget> <widget class="QMenuBar" name="menubar"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>420</width> <height>21</height> </rect> </property> </widget> <widget class="QStatusBar" name="statusbar"/> </widget> <resources/> <connections/> </ui>
你没有仔细看我问你的内容。
试试这个:
q1594978.ui: