[Qt-qml] Advanced layout support
jens.bache-wiig at nokia.com
jens.bache-wiig at nokia.com
Wed Oct 19 10:11:16 CEST 2011
> 1. Add min/max support in QtQuick
>
> * Advantages:
> - Clear and explicit API
> - Native support without 3rd party extensions
> - We could add min/max support for the QML anchoring system (like
> QGraphicsAnchorLayout)
>
> * Disadvantages:
> - I can't see any
I don't neccessarily disagree, as having it built into the language seems like the obvious solution. But I don't think it is _that_ clear cut:
- If we do not support those constraints it for anchors, but give items properties like minimum/maximumWidth, it would just add to the confusion.
- Adding constraints could have a significant performance penalty for low end hardware. Hopefully this would be negligible if you don't make use of them.
- Giving anchors hard constraints can impact how easy it is to animate certain things. Making layouts explicit makes it easier to determine when you are giving away control over positioning.
- Giving anchors constraints makes them unpredictable. Who wins when you have conflicting min/max sizes? The largest item? Most likely by random? Again, I somewhat like the distinction that anchors are somewhat more rigid/harder and wins over layouts every time.
> 2. Provide a 'Widget' element in QtComponents
> * Advantages
> - Clear and explicit API
>
> * Disadvantages
> - Add an intermediary element just to handle min/max, increasing the
> hierarchy tree.
> - Just widgets could be added to RowLayout, ColumnLayout and
> GridLayout, diverging from Row, Column and Grid idea.
I personally do not this idea because you make it much harder to mix and match regular QML with components.
Would putting an item between two widgets remove their constraints?
> Personally, I prefer the first approach. But if an immediate API is
> necessary, I would go with the 3rd approach.
I agree. I think the hybrid solution would be a good compromise. i.e that you have a Layout/SizeHint attached property in addition to RowLayout.
But I just noticed (and excuse me if it is well known) But there are actually two existing complete layout examples for GridLayout and LinearLayout that ships with Qt 4.7 already.
They both seem to favor the LayoutItem approach:
http://doc.qt.nokia.com/4.7-snapshot/declarative-cppextensions-qgraphicslayouts-qgraphicsgridlayout-qgraphicsgridlayout-qml.html
http://doc.qt.nokia.com/4.7-snapshot/declarative-cppextensions-qgraphicslayouts-qgraphicslinearlayout-qgraphicslinearlayout-qml.html
Regards,
Jens Bache-Wiig
More information about the Qt-qml
mailing list