from qtpy.QtWidgets import QApplication, QFormLayout, QLineEdit, QWidget app = QApplication([]) widget = QWidget() form = QFormLayout(widget) form.addRow("First Name", QLineEdit()) form.addRow("Last Name", QLineEdit()) form.addRow("Age", QLineEdit()) widget.show() app.exec_()
from qtpy.QtWidgets import QApplication, QFormLayout, QSpinBox, QDoubleSpinBox, QWidget app = QApplication([]) widget = QWidget() form = QFormLayout(widget) form.addRow("Quantity", QSpinBox()) form.addRow("Price per unit", QDoubleSpinBox()) form.setLabelAlignment(Qt.AlignRight) form.setFormAlignment(Qt.AlignHCenter | Qt.AlignTop) form.setHorizontalSpacing(20) widget.show() app.exec_()This creates a form with two fields: Quantity and Price per unit, each with a specific type of spin box. The form is also customized with different alignments and spacing. Both of these examples use the QFormLayout manager from the QtWidgets module of the QtPy package/library for Python.