我正在创建一个最初显示登录和注册按钮的应用程序。 点击登录我想显示另一个屏幕(或对话框),这将允许用户输入用户名和密码。单击按钮创建新对话框
,我想隐藏第一个对话框,当第二个对话框已经出现了,但没能做到这一点。(就像我们在Facebook的信使)
我们能否通过连接到点击的信号打开一个新的对话框登录按钮在Qt dsigner本身?
我已经设计了第一个屏幕在Qt Designer中,转换是的.ui文件的.py然后导入它在main.py
main.py
import sys
from Pyside.QtGui import *
from Pyside.QtCore import *
from firstscreen import Ui_Dialog
class MainDialog(QDialog, Ui_Dialog):
def __init__(self, parent=None):
super(MainDialog, self).__init__(parent)
self.setupUi(self)
self.Login.clicked.connect(self.showsecondscreen)
def showsecondscreen(self):
newScreen = QDialog(self)
newScreen.show(self)
app = QApplication(sys.argv)
form = MainDialog()
form.show()
app.exec_()
firstscreen.ui
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>322</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>My App</string>
</property>
<widget class="QPushButton" name="Login">
<property name="geometry">
<rect>
<x>110</x>
<y>110</y>
<width>98</width>
<height>27</height>
</rect>
</property>
<property name="text">
<string>Login</string>
</property>
</widget>
<widget class="QPushButton" name="Signup">
<property name="geometry">
<rect>
<x>110</x>
<y>150</y>
<width>98</width>
<height>27</height>
</rect>
</property>
<property name="text">
<string>Signup</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
是self.hide()正在工作 – Patrick
那么请标记为答案。 – St0fF