May-07-2022, 05:40 PM
What is the problem? I ran your code and everything lines up to the left.
If you want to compute the fixed width of your LineEdit you can do that using the font metrics
If you want to compute the fixed width of your LineEdit you can do that using the font metrics
import PySide6.QtWidgets as QtWidgets from PySide6.QtGui import QFontMetrics from PySide6.QtGui import Qt def fitToText(widget, text, padding=10): """Set width to fit text""" pixels = QFontMetrics(widget.font()).boundingRect(text).width() + padding widget.setFixedWidth(pixels) return pixels class MyWindow(QtWidgets.QWidget): def __init__(self): super().__init__() self.lp_label = QtWidgets.QLabel("Low-pass (Hz): ", self) self.lp_label.setAlignment(Qt.AlignLeft) self.lp_edit = QtWidgets.QLineEdit("10", self) self.lp_edit.setAlignment(Qt.AlignLeft) fixed_width = fitToText(self.lp_edit, "000.00") self.hp_label = QtWidgets.QLabel("High-pass (Hz): ", self) self.hp_label.setAlignment(Qt.AlignLeft) self.hp_edit = QtWidgets.QLineEdit("10", self) self.hp_edit.setAlignment(Qt.AlignLeft) self.hp_edit.setFixedWidth(fixed_width) self.hanning_sel = QtWidgets.QComboBox(self) self.hanning_sel.addItems(["Hanning", "Hamming", "Flat", "None"]) fitToText(self.hanning_sel, "Hamming", 30) buttonbox3 = QtWidgets.QVBoxLayout(self) buttonbox3.addWidget(self.lp_label) buttonbox3.addWidget(self.lp_edit) buttonbox3.addWidget(self.hp_label) buttonbox3.addWidget(self.hp_edit) buttonbox3.addWidget(self.hanning_sel) app = QtWidgets.QApplication() window = MyWindow() window.show() app.exec()Please provide a runnable example next time you post