Results 1 to 6 of 6

Thread: Creating a square sized widget in a layout

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2006
    Posts
    46
    Thanks
    8
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Creating a square sized widget in a layout

    Thanks - it would be nice if there was a widthForHeight() as well for completeness in the QWidget class.

  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: Creating a square sized widget in a layout

    I'm sure you can subclass QWidget and implement widthForHeight capabilities.

  3. #3
    Join Date
    Mar 2006
    Posts
    46
    Thanks
    8
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Creating a square sized widget in a layout

    True, but none of the Qt layout related classes will know about this new method. I thought that the layout classes call heightForWidth() to help calculate the layout? I may be able to find a way to trick these classes into doing what I want, but it seems like that would rely on knowing their implementation, which could change in the future.

    Quote Originally Posted by wysota
    I'm sure you can subclass QWidget and implement widthForHeight capabilities.

  4. #4
    Join Date
    Sep 2008
    Posts
    60
    Thanks
    8
    Thanked 10 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Creating a square sized widget in a layout

    I also have a need for widthForHeight() method. A container, QScrollArea, uses a custom flow layout that lays out table views in a single row. The container has horizontal scroll bar but no vertical scroll bar. The table views, on the opposite, do not have horizontal scroll bars and only have vertical scroll bars. The problem is when the container's hight gets small enough so that it cuts-off bottom parts of the tables, the tables need to display vertical scroll bars. When this happens, minimalSizeHint() and sizeHint() need to adjust for the vertical scroll bar's width. But in the Qt layout system there seems to be no way to tell a child widget to compute its width based on the vertical space that the parent can provide for the child. Any advice on how to solve this will be greatly appreciated.

    Thank you,
    Yuri

Similar Threads

  1. QDockWidget inside another widget in the center?
    By Antebios in forum Qt Programming
    Replies: 1
    Last Post: 16th February 2010, 07:06
  2. changing layout of a widget
    By mikro in forum Qt Programming
    Replies: 10
    Last Post: 4th August 2009, 20:21
  3. Resize widget force layout resizing
    By ^NyAw^ in forum Qt Programming
    Replies: 17
    Last Post: 11th February 2009, 11:27
  4. Replies: 1
    Last Post: 18th March 2006, 10:18

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.