Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to get QLabel border size ?
Ahti last edited by Ahti
I want to get border size of a QLabel object. I did a research online and found this https://stackoverflow.com/questions/27771357/qt-qlabel-border-size
but it was not helpful. and i also wanna know the default border size of QLabel
Eddy last edited by
The default border size of QLabel is platform dependent. What OS are you on?
What do you want to do with the border size?
joeQ last edited by joeQ
QFrame. You should to see
int QFrame::frameWidth() const int QFrame::lineWidth() const ///< i think should use this
and default border size of
QLabelmaybe is 1
Ahti last edited by
I am trying to fit the text in the label by keep increasing the height and width of text until it reaches the width and height of label but if border size of label is extended would it come in the way of text which would cause to hide the part of text on the edges ?
Eddy last edited by Eddy
Are you using layouts?
If you do the label will adapt automatically to the needed size of the text in the label. Qt does this for you by changing the sizehint based on the text space needed, you don't need to tinker with those details.
You can try it out yourself : make a simple QDialog based test application. Put a QLabel in it. Add a layout and make the dialog size minimal by dragging it in Qt Designer. Then hit run.
Then change the font size to something much bigger and run again. You will see the magic of Qt yourself. The program knows ther is more space needed and the dialog will adapt.
This is very important when you make versions of your program in other languages. If the translation of your label text is longer. the label will inform it's parent and it will be bigger.
More information about layouts can be found : in the docs