Reputation: 2573
I tried stylesheets with
padding:0px,
text-ident:0px;
margin:0px;
border: none;
And through code, changing the Size Policy to Expanding.
The layout inside the widget which has the label has
QHBoxLayout* lyt = new QHBoxLayout();
setLayout(lyt);
lyt->setContentsMargins(0,0,0,0);
And setting contents margins to 0 in the parent widget too.
The only way i got to make it smaller was setting Fixed size to less of the size. But the text has the word wrap property on, so it can be bigger and i cannot control that.
What should i do?
Upvotes: 2
Views: 6870
Reputation: 2573
I already found out what was happening. The margins and all the stuff was working.
The problem was related to the borders. The top and bottom borders are 5 px height. If you set a border height, no matter which margins or padding you have, it will be a barrier for the contents. I´ll create another post to see what happens here, if there is another way to fix this, and override the positions of the borders.
Thanks!
Upvotes: 0
Reputation: 12715
If you want to remove the extra spacing, then you can try the following on your layout. It worked for me.
lyt->setMargin( 0 );
lyt->setSpacing( 0 );
If you want to reduce the size of a particular QLabel, then you can set:
QLabel *myLabel = new QLabel( this );
myLabel->setMaximumWidth( MAX_WIDTH );
Upvotes: 2