Unsolved Adjust QPushButton size when I change the text
-
That helps if I know the size it needs to be, but given that I don't know a priori the size needed for the several different text contents and their translations, how do I found out how big it needs to be based on the textual content.
David
-
-
You can set the align by style sheet:
text-align:left
Just an additional note, it is related to the horizontal size policy when the button is added to a layout.
In that case if you set the horizontal size policy to Fixed / Maximum, it's width will be the minimum, but still with some margin. -
I used a style-sheet text-align:left which has worked for this case. I'm not marking it as the correct answer as I still wish to know how to size the button to the contained text.
David
-
Hi,
Can you show how you setup your button ?
-
Sorry it's a but messy but there's a bunch of controls there all on top of one-another at the same location but only one is ever shown
-
What are you using to handle your pile of widgets ?
-
In what sense? – the decision to show/hide them is based upon the conditions that apply when the dlg is shown. The ctor sets them all invisible and they are made visible as conditions determine (in this case depending on the value on one member variable).
If you're referring to layout - the GroupBox has "Broken layout" which is how I can pile 'em high in one place.
David
-
QStackedLayout is usually used when you want to have a pile of widget and only show one at a time.
-
Thanks for that pointer to StackedLayout. It encapsulates what I'm actually doing. ...