Details
-
Suggestion
-
Resolution: Unresolved
-
Not Evaluated
-
None
-
None
-
None
Description
Today, there is no good way of having layout items that has height-for-width (or widht-for-height) constraints.
In QLayout this is a "dynamic property" (each widget needs to reimplement the
virtual int heightForWidth(int)
function)
Ideas:
1. Add virtual qreal heightForWidth(qreal)
Can be added to QQuickControl, QQuickItem, or QQuickLayoutAttached. This might be the most performant option that e.g. QQuickControls can reimplement. It can be overridden by 2) below:
2a. function heightForWidth(w) {}
Of course, we could do it the same way in QML, and invoke a JS function if it exists.
2b. property real heightForWidth : width
Maybe this can be solved by having a heightForWidth property, where the contract is that it needs to depend on its width (such contract allows us to do layouting in the right order in the layout engine, i.e. we can arrange horizontally first, and then query the heightForWidth property before we layout vertically)
2c. Similar to QQuickText::implicitHeight
Whenever QQuickText (with word-wrapping turned on) changes its width, it will also change it's implicitHeight to reflect what is the height needed in order to display the whole text for the corresponding width.
Also, we should consider having widthForHeight.