Qt 5.15下Qt Designer设计的界面编译运行后窗口及组件极小几乎不可见的问题求助
Qt 5.15下Qt Designer设计的界面编译运行后窗口及组件极小几乎不可见的问题求助
各位好,我最近碰到一个特别头疼的问题:用Qt Designer设计完带各种组件和布局的界面后,编译运行起来,整个窗口和上面的所有组件都变得极小,几乎快看不见了,组件上的文字也小得没法辨认。我用的是Qt 5.15版本。
我在Qt Designer里仔细设置了窗口的初始尺寸、最小尺寸,也给各个组件安排了合理的布局,但运行后的效果完全不符合预期——窗口缩得特别离谱,组件跟着缩水,文字显示更是模糊不清,根本没法正常使用。
我已经尝试了几种解决方法,但都没效果:
- 手动调整Qt Designer里窗口和组件的尺寸属性,编译运行后依然没有变化
- 检查了操作系统的显示设置,确认缩放比例是正确设置的
- 排查了代码,确保没有直接修改组件尺寸的逻辑
下面是我的window1.ui文件内容,麻烦各位帮忙看看问题出在哪,有没有可行的解决办法?万分感谢!
<?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>Window1</class> <widget class="QMainWindow" name="Window1"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>411</width> <height>300</height> </rect> </property> <property name="minimumSize"> <size> <width>300</width> <height>300</height> </size> </property> <property name="windowTitle"> <string>Window1</string> </property> <property name="dockNestingEnabled"> <bool>true</bool> </property> <widget class="QWidget" name="centralwidget"> <widget class="QLabel" name="label"> <property name="geometry"> <rect> <x>110</x> <y>0</y> <width>141</width> <height>41</height> </rect> </property> <property name="text"> <string><html><head/><body><p><span style=" font-size:16pt; font-weight:700;">本地信息获取</span></p></body></html></string> </property> </widget> <widget class="QWidget" name="horizontalLayoutWidget"> <property name="geometry"> <rect> <x>40</x> <y>30</y> <width>291</width> <height>31</height> </rect> </property> <layout class="QHBoxLayout" name="horizontalLayout"> <item> <widget class="QLabel" name="label_2"> <property name="text"> <string>本地主机名</string> </property> </widget> </item> <item> <widget class="QLineEdit" name="localhostname"/> </item> <item> <widget class="QPushButton" name="flushlocal"> <property name="text"> <string>更新</string> </property> </widget> </item> </layout> </widget> <widget class="QWidget" name="horizontalLayoutWidget_2"> <property name="geometry"> <rect> <x>80</x> <y>230</y> <width>221</width> <height>22</height> </rect> </property> <layout class="QHBoxLayout" name="horizontalLayout_2"> <item> <widget class="QPushButton" name="hostdecoder"> <property name="text"> <string>域名解析器</string> </property> </widget> </item> <item> <widget class="QPushButton" name="messaging_simulator"> <property name="text"> <string>通信模拟器</string> </property> </widget> </item> </layout> </widget> <widget class="QGroupBox" name="groupBox"> <property name="geometry"> <rect> <x>40</x> <y>60</y> <width>321</width> <height>161</height> </rect> </property> <property name="title"> <string>GroupBox</string> </property> <widget class="QTextBrowser" name="localips"> <property name="geometry"> <rect> <x>90</x> <y>20</y> <width>221</width> <height>131</height> </rect> </property> </widget> <widget class="QLabel" name="label_1"> <property name="geometry"> <rect> <x>20</x> <y>20</y> <width>51</width> <height>20</height> </rect> </property> <property name="text"> <string>本机IP</string> </property> </widget> <widget class="QCheckBox" name="chkOnlyIPv4"> <property name="geometry"> <rect> <x>10</x> <y>50</y> <width>81</width> <height>22</height> </rect> </property> <property name="text"> <string>IPv4 only</string> </property> </widget> </widget> </widget> <widget class="QMenuBar" name="menubar"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>411</width> <height>21</height> </rect> </property> </widget> <widget class="QStatusBar" name="statusbar"/> </widget> <resources/> <connections/> </ui>
备注:内容来源于stack exchange,提问作者LEO
相关产品推荐
相关产品推荐

