我的PyQt应用程序从登录屏幕开始。如果密码正常,将显示模块屏幕(带图标)。当用户单击某个按钮时,将出现一个QMainWindow。但我不能这样做,因为qmainwindow对象没有属性''u exec'错误。这是我的代码:
from PyQt4.QtGui import *
from PyQt4.QtCore import *
class Main(QMainWindow):
def __init__(self, parent=None):
super(Main, self).__init__(parent)
...
...
class Login(QDialog):
def __init__(self, parent=None):
super(Login, self).__init__(parent)
...
...
uyg=QApplication(sys.argv)
class icons(QDialog):
def __init__(self, parent=None):
super(icons, self).__init__(parent)
...
self.buton = QPushButton()
self.buton.pressed.connect(self.open)
...
def open(self):
dialogmain = Main()
dialogmain._exec() #or dialogmain.show() ???
self.accept()
self.close()
uyg.exec_()
if Login().exec_() == QDialog.Accepted:
dialog = icons()
dialog.exec_()
else:
uyg.quit()
我做错什么了?非常感谢。在
除了应用程序对象和}不存在。这是一个完全令人困惑的方法,根本不必使用。尤其是那些不熟悉Qt的人。在
QDrag
,请假设{如果要显示任何小部件,只需
show()
它。如果您想在对话框被接受时得到通知,请将一些代码连接到其accepted()
信号。这就是全部。在最近我也做过类似的事工作:我有一个登录窗口和一个主窗口,我用一个类似FMS的东西在登录窗口和主窗口之间切换。 假设我们有3个状态:登录,main,退出。在
相关问题 更多 >
编程相关推荐