QLabel top and bottom padding is not getting set to zero.
Hello,
I am trying to make the top and bottom padding zero in my QLabel. I have tried all the options below but none of them seem to work.
Am i missing something? In smaller fonts, the padding is negligible. As the font size increases(in my case 192 Sans Serif), the top and bottom padding are too big to ignore.
QLabel *newLabel = new QLabel("Text", this);
this->setStyleSheet("QLabel { border: 0px; }");
newLabel->setAlignment(Qt::AlignTop);
newLabel->setStyleSheet("background-color: yellow; color: blue; font-size: 192px; padding: 0 0 0 0px; border: 0 0 0 0px");
newLabel->setIndent(0);
newLabel->setMargin(0);
newLabel->setContentsMargins(0, 0, 0, 0);
newLabel->setFrameShape(QFrame::HLine);
newLabel->setFrameStyle(QFrame::NoFrame);
Is there anything I must try?
Any help would be greatly appreciated as this is really bothering me.
Thank you.
Re: QLabel top and bottom padding is not getting set to zero.
Maybe it isn't the label at all, but the layout or other place where you are embedding it?
Re: QLabel top and bottom padding is not getting set to zero.
Hello,
Thanks for your response
I've tried setting the layout and the central Widgets contents Margins to zero as well. That doesn't help. This can be seen in a simple qt app which has two labels.
Added after 4 minutes:
Also, yesterday i tried to set negative padding which works, so I'm convinced it has something to do with the label. However, I am not sure if that's a good idea as the font size is configurable.
Re: QLabel top and bottom padding is not getting set to zero.
Quote:
Originally Posted by
Vinaya
Hello,
Thanks for your response
I've tried setting the layout and the central Widgets contents Margins to zero as well. That doesn't help. This can be seen in a simple qt app which has two labels.
Added after 4 minutes:
Also, yesterday i tried to set negative padding which works, so I'm convinced it has something to do with the label. However, I am not sure if that's a good idea as the font size is configurable.
Strange, I had sort of the same problem and layout.setContentsMargin(0,0,0,0) solved it