pyside6窗口间传递信息,注册窗口信息返回登录窗口

from PySide6.QtWidgets import QApplication, QMainWindow, QDialog, QLabel, QVBoxLayout, QLineEdit, QPushButton, QWidget

class RegisterWindow(QDialog):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.setWindowTitle("Register Window")
        layout = QVBoxLayout()

        self.username_label = QLabel("Username:")
        self.username_edit = QLineEdit()
        layout.addWidget(self.username_label)
        layout.addWidget(self.username_edit)

        self.password_label = QLabel("Password:")
        self.password_edit = QLineEdit()
        layout.addWidget(self.password_label)
        layout.addWidget(self.password_edit)

        self.register_button = QPushButton("Register")
        self.register_button.clicked.connect(self.register)
        layout.addWidget(self.register_button)

        self.setLayout(layout)

    def register(self):
        # 注册逻辑处理...
        self.accept()

class LoginWindow(QMainWindow):
    def __init__(self):
        super().__init__()
        self.setWindowTitle("Login Window")
        layout = QVBoxLayout()

        self.username_label = QLabel("Username:")
        self.username_value_label = QLabel("")
        layout.addWidget(self.username_label)
        layout.addWidget(self.username_value_label)

        self.password_label = QLabel("Password:")
        self.password_value_label = QLabel("")
        layout.addWidget(self.password_label)
        layout.addWidget(self.password_value_label)

        self.register_button = QPushButton("Open Register Window")
        self.register_button.clicked.connect(self.open_register_window)
        layout.addWidget(self.register_button)

        central_widget = QWidget()
        central_widget.setLayout(layout)
        self.setCentralWidget(central_widget)

    def open_register_window(self):
        register_window = RegisterWindow(self)
        if register_window.exec() == QDialog.Accepted:
            username = register_window.username_edit.text()
            password = register_window.password_edit.text()
            self.username_value_label.setText(username)
            self.password_value_label.setText(password)

app = QApplication([])
login_window = LoginWindow()
login_window.show()
app.exec()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

扮作大侠

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值