Results 1 to 4 of 4

Thread: Pushbuttons with fixed aspect ratios?

  1. #1
    Join Date
    Jun 2007
    Posts
    62
    Thanks
    28
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Pushbuttons with fixed aspect ratios?

    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?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Pushbuttons with fixed aspect ratios?

    Take a look at baseSize and sizeIncrement.

  3. #3
    Join Date
    Jun 2007
    Posts
    62
    Thanks
    28
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Pushbuttons with fixed aspect ratios?

    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.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Pushbuttons with fixed aspect ratios?

    In that case you might want to subclass the button class and use heightForWidth to return a square size.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.