I want labels on the left to all have the same horizontal length while text aligned to the left. Their vertical size equals vertical size of the respective right widget.
Labels on the right to take as little space as possible. Basically remove indents around text.
Something like below.
I have this code.
import sys
from PyQt5.QtCore import Qt
from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QLabel, QHBoxLayout
class Window2(QWidget):
def __init__(self):
super().__init__()
self.setWindowTitle("About")
vbox = QVBoxLayout()
hboxes = list()
disclaimer = {
'Text': """
some text
""",
'Longer text': """
longer text longer text text longer text longer
"""
}
for label, text in disclaimer.items():
hbox = QHBoxLayout()
for t in (label, text):
l = QLabel(t)
l.setAlignment(Qt.AlignLeft)
l.setStyleSheet('border-style: solid; border-width: 1px; border-color: black;')
hbox.addWidget(l)
vbox.addLayout(hbox)
self.setLayout(vbox)
self.show()
if __name__ == '__main__':
app = QtWidgets.QApplication(sys.argv)
main_window = Window2()
sys.exit(app.exec_())
I can't seem to figure out how it works/what is margin, indent, padding, spacing, stretch etc. Please help me understand and solve this problem.