code: def add_cancel_button(self):
          
          button_box = QDialogButtonBox(QDialogButtonBox.Cancel, self)
          button_box.rejected.connect(self.reject)
          self.layout.addWidget(button_box)
docs: Add a cancel button at the bottom of the dialog window.