我使用qt设计器创建了一个接口,并使用pyqt5将其集成到我的python代码中。然后我用pyinstaller创建了一个exe文件,这个界面在我使用Windows10 Home的笔记本电脑上显示得很好。但是,在使用Windows10 Pro的其他Windows计算机上进行测试时,会显示所有按钮和标签都已被剪切,字体错误,如下所示。例如,顶部标题应该是地理距离计算器,但只显示“地理距离CA”。是什么导致了这种不兼容,我如何修复它?
对于希望在其上测试示例的任何人,我都有下面的示例代码:
from pyqt5 import uic,qtwidgets
导入系统
app=qtwidgets.qapplication(系统argv)
window=uic.loadui('interface.ui')
显示窗口()
系统退出(app.exec_u())
< /代码>
从qt designer派生的UI文件的完整代码如下所示,可以通过将代码复制和粘贴到文本编辑器并将文件保存为“interface.ui”:来重新创建该文件。
<?xml version=“1.0”encoding=“utf-8”?gt;
<ui version=“4.0”>
<class>主窗口</class>
<widget class=“qmainwindow”name=“mainwindow”>
<property name=“geometry”>
R&T;
<X>0</X>
<Y>0</Y>
<width>745</width>
<height>534</height>
&;
</property>
<property name=“font”>
字体& gt;
<pointsize>28</pointsize>
<weight>75</weight>
<bold>真</bold>
&字体/字体;
</property>
<property name=“windowtitle”>
<string>地理距离专业版</string>
</property>
<property name=“stylesheet”>
<string notr=“true”>qmainwindow{
背景色:RGB(25、31、63);
}</string>
</property>
<widget class=“qwidget”name=“centralwidget”>
<widget class=“qlabel”name=“label”>
<property name=“geometry”>
R&T;
<x>-70</x>
<Y>10</Y>
<width>811</width>
<height>231</height>
&;
</property>
<property name=“stylesheet”>
<string notr=“true”>背景图像:url(:/newprefix/shutterstock-488566735.png);</string>
</property>
<property name=“text”>
&串/ gt;
</property>
& /小部件& GT;
<widget class=“qlabel”name=“label_2”>
<property name=“geometry”>
R&T;
<x>70</x>
<Y>120</Y>
<width>601</width>
<height>71</height>
&;
</property>
<property name=“Palette”>
<调色板>
活性;
<colorRole role=“windowtext”>
<brush brushStyle=“solidPattern”>
<color alpha=“255”>
<red>255</red>
<green>255</green>
<blue>255</blue>
& /颜色& gt;
&刷子& gt;
</colorrole>
<colorRole role=“text”>
<brush brushStyle=“solidPattern”>
<color alpha=“255”>
<red>255</red>
<green>255</green>
<blue>255</blue>
& /颜色& gt;
&刷子& gt;
</colorrole>
<colorRole role=“buttonText”>
<brush brushStyle=“solidPattern”>
<color alpha=“255”>
<red>255</red>
<green>255</green>
<blue>255</blue>
& /颜色& gt;
&刷子& gt;
</colorrole>
&Lt//Active & Gt;
<不活动>
<colorRole role=“windowtext”>
<brush brushStyle=“solidPattern”>
<color alpha=“255”>
<red>255</red>
<green>255</green>
<blue>255</blue>
& /颜色& gt;
&刷子& gt;
</colorrole>
<colorRole role=“text”>
<brush brushStyle=“solidPattern”>
<color alpha=“255”>
<red>255</red>
<green>255</green>
<blue>255</blue>
& /颜色& gt;
&刷子& gt;
</colorrole>
<colorRole role=“buttonText”>
<brush brushStyle=“solidPattern”>
<color alpha=“255”>
<red>255</red>
<green>255</green>
<blue>255</blue>
& /颜色& gt;
&刷子& gt;
</colorrole>
</inactive>
<已禁用>
<colorRole role=“windowtext”>
<brush brushStyle=“solidPattern”>
<color alpha=“255”>
<red>120</red>
<green>120</green>
<blue>120</blue>
& /颜色& gt;
&刷子& gt;
</colorrole>
<colorRole role=“text”>
<brush brushStyle=“solidPattern”>
<color alpha=“255”>
<red>120</red>
<green>120</green>
<blue>120</blue>
</color>
&刷子& gt;
</colorrole>
<colorRole role=“buttonText”>
<brush brushStyle=“solidPattern”>
<color alpha=“255”>
<red>120</red>
<green>120</green>
<blue>120</blue>
& /颜色& gt;
&刷子& gt;
</colorrole>
</disabled>
</Palette>
</property>
<property name=“font”>
字体& gt;
<family>罗曼克</family>
<pointsize>28</pointsize>
<weight>50</weight>
<bold>错误</bold>
&字体/字体;
</property>
<property name=“autofillbackground”>
<bool>错误</bool>
</property>
<property name=“text”>
<string>地理距离计算器</string>
</property>
& /小部件& GT;
<widget class=“qlabel”name=“label_4”>
<property name=“geometry”>
R&T;
<x>10</x>
<Y>270</Y>
<width>181</width>
<height>31</height>
</rect>
</property>
<property name=“font”>
字体& gt;
<pointsize>12</pointsize>
<weight>75</weight>
<bold>真</bold>
&字体/字体;
</property>
<property name=“stylesheet”>
<string notr=“true”>颜色:RGB(255、255、255);</string>
</property>
<property name=“text”>
<string>开始郊区</string>
</property>
& /小部件& GT;
<widget class=“qlineedit”name=“lineedit”>
<property name=“geometry”>
R&T;
<x>210</x>
<Y>270</Y>
<width>301</width>
<height>41</height>
&;
</property>
<property name=“font”>
字体& gt;
<pointsize>11</pointsize>
<weight>75</weight>
<bold>真</bold>
&字体/字体;
</property>
& /小部件& GT;
<widget class=“qpushButton”name=“pushbutton”>
<property name=“geometry”>
R&T;
<x>520</x>
<Y>430</Y>
<width>141</width>
<height>61</height>
</rect>
</property>
<property name=“font”>
字体& gt;
<pointsize>11</pointsize>
<weight>75</weight>
<bold>真</bold>
</FONT>
</property>
<property name=“cursor”>
<cursorshape>指向和光标</cursorshape>
</property>
<property name=“text”>
<string>输入</string>
</property>
& /小部件& GT;
<widget class=“qlabel”name=“label_5”>
<property name=“geometry”>
R&T;
<x>10</x>
<Y>340</Y>
<width>181</width>
<height>31</height>
&;
</property>
<property name=“font”>
字体& gt;
<pointsize>12</pointsize>
<weight>75</weight>
<bold>真</bold>
&字体/字体;
</property>
<property name=“stylesheet”>
<string notr=“true”>颜色:RGB(255、255、255);</string>
</property>
<property name=“text”>
<string>每公里票价</string>
</property>
& /小部件& GT;
<widget class=“qlabel”name=“label_6”>
<property name=“geometry”>
<rect>
<x>10</x>
<Y>450</Y>
<width>181</width>
<height>31</height>
&;
</property>
<property name=“font”>
字体& gt;
<pointsize>12</pointsize>
<weight>75</weight>
<bold>真</bold>
&字体/字体;
</property>
<property name=“stylesheet”>
<string notr=“true”>颜色:RGB(255、255、255);</string>
</property>
<property name=“text”>
<string>政府征费($)</string>
</property>
</widget>
<widget class=“qlabel”name=“label_7”>
<property name=“geometry”>
R&T;
<x>10</x>
<Y>390</Y>
<width>171</width>
<height>31</height>
&;
</property>
<property name=“font”>
字体& gt;
<pointsize>12</pointsize>
<weight>75</weight>
<bold>真</bold>
&字体/字体;
</property>
<property name=“stylesheet”>
<string notr=“true”>颜色:RGB(255、255、255);
&Lt/String & Gt;
</property>
<property name=“text”>
<string>折扣</string>
</property>
& /小部件& GT;
<widget class=“qlineedit”name=“lineedit_2”>
<property name=“geometry”>
R&T;
<x>210</x>
<Y>330</Y>
<width>111</width>
<height>41</height>
</rect>
</property>
<property name=“font”>
字体& gt;
<pointsize>12</pointsize>
<weight>75</weight>
<bold>真</bold>
&字体/字体;
</property>
& /小部件& GT;
<widget class=“qlineedit”name=“lineedit_3”>
<property name=“geometry”>
R&T;
<x>210</x>
<Y>380</Y>
<width>111</width>
<height>41</height>
&;
</property>
<property name=“font”>
字体& gt;
<pointsize>12</pointsize>
<weight>75</weight>
<bold>真</bold>
&字体/字体;
</property>
& /小部件& GT;
<widget class=“qlineedit”name=“lineedit_4”>
<property name=“geometry”>
R&T;
<x>210</x>
<Y>440</Y>
<width>111</width>
<height>41</height>
&;
</property>
<property name=“font”>
字体& gt;
<pointsize>12</pointsize>
<weight>75</weight>
<bold>真</bold>
&字体/字体;
</property>
& /小部件& GT;
& /小部件& GT;
<widget class=“qmenubar”name=“menubar”>
<property name=“geometry”>
R&T;
<X>0</X>
<Y>0</Y>
<width>745</width>
<height>21</height>
&;
</property>
& /小部件& GT;
<widget class=“qstatusbar”name=“statusbar”/>
& /小部件& GT;
<资源>
<include location=“阿德莱德.qrc”/>
<include location=“filex.qrc”/>
</resources>
<连接/>
& lt//u& & gt;
< /代码> <使用Windows10 Home在我的笔记本电脑上显示很好。但是,在使用Windows10 Pro的其他Windows计算机上进行测试时,会显示所有按钮和标签都已被剪切,字体错误,如下所示。例如,顶部标题应该是地理距离计算器,但只显示“地理距离CA”。是什么导致了这种不兼容,我如何修复它?
对于希望在其上测试示例的任何人,我都有下面的示例代码:
from PyQt5 import uic, QtWidgets
import sys
app = QtWidgets.QApplication(sys.argv)
window = uic.loadUi('interface.ui')
window.show()
sys.exit(app.exec_())
从qt designer派生的UI文件的完整代码如下所示,可以通过将代码复制和粘贴到文本编辑器并将文件保存为“interface.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>745</width>
<height>534</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>28</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="windowTitle">
<string>GEODISTANCE PRO</string>
</property>
<property name="styleSheet">
<string notr="true">QMainWindow{
background-color: rgb(25, 31, 63);
}</string>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>-70</x>
<y>10</y>
<width>811</width>
<height>231</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">background-image: url(:/newPrefix/shutterstock-488566735.png);</string>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>70</x>
<y>120</y>
<width>601</width>
<height>71</height>
</rect>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Text">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="ButtonText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Text">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="ButtonText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>120</red>
<green>120</green>
<blue>120</blue>
</color>
</brush>
</colorrole>
<colorrole role="Text">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>120</red>
<green>120</green>
<blue>120</blue>
</color>
</brush>
</colorrole>
<colorrole role="ButtonText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>120</red>
<green>120</green>
<blue>120</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="font">
<font>
<family>RomanC</family>
<pointsize>28</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="text">
<string>GEODISTANCE CALCULATOR</string>
</property>
</widget>
<widget class="QLabel" name="label_4">
<property name="geometry">
<rect>
<x>10</x>
<y>270</y>
<width>181</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(255, 255, 255);</string>
</property>
<property name="text">
<string> STARTING SUBURB</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit">
<property name="geometry">
<rect>
<x>210</x>
<y>270</y>
<width>301</width>
<height>41</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
</widget>
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>520</x>
<y>430</y>
<width>141</width>
<height>61</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="text">
<string>ENTER</string>
</property>
</widget>
<widget class="QLabel" name="label_5">
<property name="geometry">
<rect>
<x>10</x>
<y>340</y>
<width>181</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(255, 255, 255);</string>
</property>
<property name="text">
<string> FARE PER KM</string>
</property>
</widget>
<widget class="QLabel" name="label_6">
<property name="geometry">
<rect>
<x>10</x>
<y>450</y>
<width>181</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(255, 255, 255);</string>
</property>
<property name="text">
<string> GOVT LEVY ($)</string>
</property>
</widget>
<widget class="QLabel" name="label_7">
<property name="geometry">
<rect>
<x>10</x>
<y>390</y>
<width>171</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(255, 255, 255);
</string>
</property>
<property name="text">
<string> DISCOUNT</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_2">
<property name="geometry">
<rect>
<x>210</x>
<y>330</y>
<width>111</width>
<height>41</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_3">
<property name="geometry">
<rect>
<x>210</x>
<y>380</y>
<width>111</width>
<height>41</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_4">
<property name="geometry">
<rect>
<x>210</x>
<y>440</y>
<width>111</width>
<height>41</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
</widget>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>745</width>
<height>21</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources>
<include location="adelaide.qrc"/>
<include location="filex.qrc"/>
</resources>
<connections/>
</ui>