May 2019
Intermediate to advanced
542 pages
13h 37m
English
Qt contains other dialog box classes for selecting colors, requesting input values, and more. All of these work more or less like the file and font dialog boxes, and they descend from the QDialog class. We can subclass QDialog ourselves to create a custom dialog box.
For example, suppose we want to have a dialog box for entering our settings. We could start building it like this:
class SettingsDialog(qtw.QDialog): """Dialog for setting the settings""" def __init__(self, settings, parent=None): super().__init__(parent, modal=True) self.setLayout(qtw.QFormLayout()) self.settings = settings self.layout().addRow( qtw.QLabel('<h1>Application Settings</h1>'), ) self.show_warnings_cb = qtw.QCheckBox( checked=settings.get('show_warnings') ...Read now
Unlock full access