2021年5月5日星期三

How to make a close button in PySide6 if there is a UI file

I want to make a simple dialog in PySide6 (I'm currently learning Python) but I can't figure out how to call a button from my ui file (the button I want to use is called closeButton) so I can make it close the window when I click it.

Edit: im using QWidgets

Edit 2: here is a "little" snippet of code

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_())  
https://stackoverflow.com/questions/67405061/how-to-make-a-close-button-in-pyside6-if-there-is-a-ui-file May 06, 2021 at 12:18AM

没有评论:

发表评论