Widget | What it does |
---|---|
QCheckbox | A checkbox |
QComboBox | A dropdown list box |
QDateEdit | For editing dates and datetimes |
QDateTimeEdit | For editing dates and datetimes |
QDial | Rotatable dial |
QDoubleSpinbox | A number spinner for floats |
QFontComboBox | A list of fonts |
QLCDNumber | A quite ugly LCD display |
QLabel | Just a label, not interactive |
QLineEdit | Enter a line of text |
QProgressBar | A progress bar |
QPushButton | A button |
QRadioButton | A toggle set, with only one active item |
QSlider | A slider |
QSpinBox | An integer spinner |
QTimeEdit | For editing times |
Layout | Behaviour |
---|---|
QHBoxLayout | Linear horizontal layout |
QVBoxLayout | Linear vertical layout |
QGridLayout | In indexable grid XxY |
QStackedLayout | Stacked (z) in front of one another |
filled from top to bottom.
filled from left to right.
widgets arranged in a grid
Multiple widgets in the same space
.addLayout
을 이용해 layout을 nesting 할 수 있음.
class MainWindow(QMainWindow):
def __init__(self):
super(MainWindow, self).__init__()
self.setWindowTitle("My App")
layout1 = QHBoxLayout()
layout2 = QVBoxLayout()
layout3 = QVBoxLayout()
layout2.addWidget(Color('red'))
layout2.addWidget(Color('yellow'))
layout2.addWidget(Color('purple'))
layout1.addLayout( layout2 )
layout1.addWidget(Color('green'))
layout3.addWidget(Color('red'))
layout3.addWidget(Color('purple'))
layout1.addLayout( layout3 )
widget = QWidget()
widget.setLayout(layout1)
self.setCentralWidget(widget)