eugene
eugene

Reputation: 71

How to limit QPushButton from bieng smaller then the size of its text?

Unexpectedly for myself I found out that buttons impudently ignore the size of the text and easily cut it with a decrease. Is there something like sizeAdjustPolicy as at QComboBox? If not, what is the correct decision? In Google and other places I didn't find anything intelligible. Thanks in advance! edit2: I used Qt Style Sheets, cleaned - works fine. Have to give up beauty.

Solution: it was in Qt Style Sheets. If there to use min-width property then something spoils and the button ignores the text size.

Upvotes: 2

Views: 1662

Answers (3)

eugene
eugene

Reputation: 71

It was in Qt Style Sheets. If there to use min-width property then something spoils and the button ignores the text size.

Upvotes: 2

To prevent a button from getting too small, set its horizontal size policy to MinimumExpanding. I don't see a reason to use stylesheets for that.

If you wish to manage the size of the button yourself, you can get the minimum size hint of any control by using the minimumSizeHint method.

Upvotes: 2

Bowdzone
Bowdzone

Reputation: 3864

You can refer to this question to determine the text size and set the button width according to it using QFontMetrics.

Upvotes: 0

Related Questions