我是PyQt的新手,我已经用Qt Designer和PyQt5设计了一个非常基本的程序。我在执行具有简单代码以显示名称的按钮时遇到错误。
Error: Process finished with exit code -1073740791 (0xC0000409)
通读一些帖子,人们说这可能与内核有关。一种解决方案是包括app.aboutToQuit.connect(app.deleteLater)并替换app.exec_()。但这并不能解决
这是我要运行的程序
我想知道我的语法是否有问题或缺少其他内容。
我的python代码附在下面
import sys
from PyQt5.QtWidgets import QMainWindow, QApplication
from PyQt5 import uic
Ui_MainWindow, QtBaseClass = uic.loadUiType("simple.ui")
class MyApp(QMainWindow):
def __init__(self):
super(MyApp, self).__init__()
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.ui.pushButton.clicked.connect(self.DisplayName)
def DisplayName(self):
name = 'Hello' + str(self.lineEdit.text())
self.lineEdit.setText(name)
if __name__ == "__main__":
app = QApplication(sys.argv)
window = MyApp()
window.show()
sys.exit(app.exec_())
这是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>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QLineEdit" name="lineEdit">
<property name="geometry">
<rect>
<x>282</x>
<y>130</y>
<width>121</width>
<height>31</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>200</x>
<y>140</y>
<width>71</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Message</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>410</x>
<y>130</y>
<width>93</width>
<height>28</height>
</rect>
</property>
<property name="text">
<string>Welcome</string>
</property>
</widget>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>26</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>
谢谢