문제

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?

도움이 되었습니까?

해결책

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.

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top