关于PyQt5,在pycharm上的安装步骤及使用技巧(最重要)
https://www.cnblogs.com/pywjh/p/9835931.html
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow
from MyFirstUI import *
class MyMainWindow(QMainWindow, Ui_MainWindow):
def __init__(self, parent=None):
super(MyMainWindow, self).__init__(parent)
self.setupUi(self)
if __name__ == '__main__':
app = QApplication(sys.argv)
myWin = MyMainWindow()
myWin.show()
sys.exit(app.exec_())
Pycharm配置pyqt5
https://blog.csdn.net/weixin_45861045/article/details/121068890
[QT入门篇]三大窗口类介绍
PyQt5,弹窗,自定义输入对话框
‘QMainWindow‘ object has no attribute ‘accept‘
import sys
from PyQt5.QtWidgets import QApplication, QDialog, QMainWindow
import Ui_mainwin
if __name__ == '__main__':
app = QApplication(sys.argv)
MainWindow = QMainWindow()
ui = Ui_mainwin.Ui_Dialog()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
主要是由于创建的ui类别不是MainWindow,而应该改为Dialog,才能使用界面中的OK CANCEL等QDialogButtonBox类的按钮
解决方法就是将MainWindow = QMainWindow() 改为 MainWindow = QDialog()即可
此时跳出的界面中的确定和取消按钮也可以正常使用
标签:__,QMainWindow,配置,pyqt5,Ui,PyQt5,import,Pycharm,MainWindow From: https://www.cnblogs.com/hongdoudou/p/17183334.html