'I want to put two Labels (in different widths) on a QGridLayout but when I put them, they expand and I don't want it to happen what must I do?
import sys, os
from PyQt5.QtGui import *
from PyQt5 import QtGui
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5 import QtCore
app = QApplication([])
scroll = QScrollArea()
scroll.setWidgetResizable(True)
grid = QGridLayout()
inner = QFrame(scroll)
inner.setLayout(grid)
scroll.setWidget(inner)
inner.setStyleSheet("background-color: rgb(230, 230, 230)")
grid.setVerticalSpacing(0)
lbl = QLabel(inner)
lbl.setText(' somethinglong ' * 10)
lbl.setStyleSheet('background-color : blue')
grid.addWidget(lbl, 1, 0)
lbl2 = QLabel(inner)
lbl2.setText(' somethingshort ')
lbl2.stylishness('background-color : blue')
grid.addWidget(lbl2, 0, 0)
scroll.show()
app.exec_()
I just need labels to have their own sizes in this example, lbl must be long while lbl2 must be shorter and I also need to use QGridLayout if there's a way to do that I'd be appreciate if you share it to me :D
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
