Question

Ok, here is my problem:

I have a vertical layout which contains a QPlainTextEdit and a horizontal layout (containing 2 QPushButtons) below the text edit.

The vertical layout is just a part of GUI, and gets resized depending on screen resolution. Btw. it is a mobile app, so I don't have a lot of space on screen.

Push buttons have some text which is dynamically set, I don't know it from the beginning to code it manually.

My problem occurs when the text in push buttons is big, and my whole vertical layout is expanded to fit the buttons.

How can I make the vertical layout unexpandable? note, that this is different from "fixed" because of different screen resoulutions. I'd just like the clip the buttons if they do not fit, but keep the layout width untouched.

Anyway to do this?

Was it helpful?

Solution

You'll need to set the maximum width for the buttons, not the layout, which is only widening to fit the wider buttons. Check out the docs on QPushButton and look for QWidget inherited functions called setMaximumSize or setMaximumWidth.

OTHER TIPS

You can always GetWidth() on the button when it is an appropriate size, then setMaximumWidth using that value since you wouldn't ordinarily know this. Pick an appropriate default text size/val and use that to create your "dynamic" default since this is going on screens of varying size.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top