Thanks - it would be nice if there was a widthForHeight() as well for completeness in the QWidget class.
Thanks - it would be nice if there was a widthForHeight() as well for completeness in the QWidget class.
I'm sure you can subclass QWidget and implement widthForHeight capabilities.
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.
Originally Posted by wysota
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
Bookmarks