Results 1 to 2 of 2

Thread: Expand and keep ratio

  1. #1
    Join Date
    Oct 2008
    Location
    Beijing China
    Posts
    77
    Thanks
    21
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Smile Expand and keep ratio

    Hi.
    How to make a widget expand both horizontally and vertically and keep the ratio width by height in the same time.
    i mean, if i want the width / height is always 4/3, and occupy as more as possible space.

    expected result:
    case1: available width = 100, available height = 100, then the widget is expected to be 100 in width and 75 in height;
    case2: available width = 100, available height = 60, then the widget should be 80-wide and 60-high.

    Have i describe the issue clearly? Thanks in advance for any suggestion.

  2. #2
    Join Date
    Sep 2008
    Posts
    18
    Thanks
    2
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Expand and keep ratio

    Hi,

    I never used this myself so I can't give an example, but I suspect QWidget::heightForWidth is what you're looking for. Reimplement this method in your widget to get the dimensions you want.

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.