如果有 UI 文件,如何在 PySide6 中制作关闭按钮

问题描述

我想在 PySide6 中创建一个简单的对话框(我目前正在学习 Python)但是我不知道如何从我的 ui 文件调用一个按钮(我想使用的按钮叫做 closeButton ) 这样我就可以在单击它时关闭窗口。

编辑:我正在使用 QWidgets

编辑 2:这是一个“小”代码片段

class dialogattempt(QWidget):
    def __init__(self):
        super(dialogattempt,self).__init__()
        self.load_ui()

    def load_ui(self):
        loader = quiloader()
        path = os.fspath(Path(__file__).resolve().parent / "form.ui")
        ui_file = QFile(path)
        ui_file.open(QFile.ReadOnly)
        loader.load(ui_file,self)
        ui_file.close()
        self.setwindowTitle("An attempt at a dialog")
    if __name__ == "__main__":
        app = QApplication([])
        widget = dialogAttempt()
        widget.show()
        sys.exit(app.exec_())

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)