How to get rid of extra padding on top and bottom of QLabel?
Solved
General and Desktop
-
When I create a QLabel, it has extra space at the top and bottom by standard, how do I remove it?
When i use
padding: 0; margin: 0
, nothing changes.auto layout = new QVBoxLayout(this); layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(1); auto label1 = new QLabel("Label1", this); label1->setStyleSheet("background-color: black; font-size: 50px; padding: 0; margin: 0;"); auto label2 = new QLabel("Label2", this); label2->setStyleSheet("background-color: black; font-size: 50px; padding: 0; margin: 0;"); layout->addStretch(); layout->addWidget(label1); layout->addWidget(label2); layout->addStretch();
You can see extra padding highlighted with red frames on the image.
-