[Qt-qml] Advanced layout support
Adriano Rezende
adriano.rezende at openbossa.org
Mon Oct 17 17:07:59 CEST 2011
On Mon, Oct 17, 2011 at 6:01 AM, <jens.bache-wiig at nokia.com> wrote:
>> I would like to get a feedback about this API, suggestions or any
>> extra feature that would make sense to add.
>
> Just repeating some points from the private discussions we had. I think it makes sense to center items at their baseline by default. (by setting the y-coordinate, so that anchoring still works) Basically by adding a VerticalAlignment property to RowLayout etc. I regularly find myself annoyed by having to explicitly centering every item in a row or column.
I end up in the same situation several times. Most of the times when I
need to add items dynamically, so the items need to be anchored to a
'non-existent' parent in order to be aligned correctly, or you need to
create a wrapper to encapsulate the item.
Having a default alignment in layout would help these cases a lot, but
raises the question how will we handle concurrent alignments (per
layout and per item)?
For example:
RowLayout {
verticalAlignment: "AlignVCenter"
Item {
id: item1
}
Item {
id: item2
anchors.bottom: parent.bottom
}
}
The item2 would be positioned at the bottom or aligned at the center?
I think the best approach would be to apply the default layout just
for items without vertical anchors, but in order to do that we need
some metaobject introspections since anchors are declared in the
QDeclarativeItem's private class, which is kind of ugly.
>> Regarding QtQuick2, I would like to bring to discussion if such
>> support should be added for the Row, Column and Grid elements. That
>> would provide a better integration with QtCreator.
> I think you should post that question on the qt-qml mailing list. I am not sure how many of the core developers that follow the components list and this can affect generic Qt Quick in general. In any case, I think we could provide a standard Layout attached property that we can use on any item that has layout management. Including Splitters as well. So Row in that example, it would still have Layout.sizePolicy as an attached property.
We are already in the qt-qml mailing list :).
I kind of agree, but I'm not sure yet if using "Layout" for any item
would be clear in the API level. At least the docs should explicitly
indicates that an item accepts this common Layout attachment. Another
problem is, for example, in the GridLayout; there are some common
properties like stretching that should be in Layout, but others like
span, shouldn't be there since it's just used by the Grid. So, maybe a
GridLayout would be better in this case, to avoid adding specific
properties in the Layout attachment.
Cheers,
Adriano
More information about the Qt-qml
mailing list