PDA

View Full Version : Pushbuttons with fixed aspect ratios?



WinchellChung
19th December 2007, 14:38
I'm back with another stupid newbie question.

I have an app with a screen with a row of QPushbuttons. The customer wishes to be able to re-size the screen and have the buttons re-size with it. But they want the buttons to maintain their aspect ratio. That is, if a button is twice as wide as it is tall, it should keep that ratio of width to height no matter how the button changes its size.

I have experimented with various size policies in Qt Designer, but none of them seem to command the button(s) to obey the initial aspect ratio. Am I missing something? Or is there a way to do this programatically?

wysota
19th December 2007, 14:44
Take a look at baseSize and sizeIncrement.

WinchellChung
19th December 2007, 16:44
Thank you. Unfortunately it appears that I am out of luck. I am developing for the Windows platform.

In the documentation for sizeIncrement it says: Warning: The size increment has no effect under Windows, and may be disregarded by the window manager on X.

I did try setting the QPushButtons' size increment to 1,1 and the base size to the desired values, but in the application it had no apparent effect with respect to maintaining the aspect ratio while the window was re-sized.

Thank you anyway.

wysota
19th December 2007, 18:38
In that case you might want to subclass the button class and use heightForWidth to return a square size.