Jason, how could ListView know the size of elements inside it? ListView instantiates and destroys elements on demand. It maintains some amount of content to show what's visible + a little more and you can get its height via contentHeight.
However, contentHeight itself is dependent on the amount of height available (and the data model). So it is available only after ListView is fully constructed. If your model has small amount of elements and delegates are small, you can resize ListView after construction so that it fits everything. Here is an example: http://pastebin.com/qsTp7QT5 Note, however, that this example assumes the ListView instantiates the whole model during construction - that is unreliable and won't work for all possible models. Artem. On Aug 25, 2011, at 5:14 AM, Jason H wrote: > So no one's solution was what I was looking for. > > One solution multiplied the number of items by the height of one, which > assumes a uniform height. > The other ListView.view.contentHeight did not work as it was undefined. > > How can I set the ListView height to the height of all the items, including > when they are changing size? > > > From: Jason H <[email protected]> > To: Juha Turunen <[email protected]>; "[email protected]" <[email protected]> > Sent: Wednesday, August 24, 2011 9:47 AM > Subject: Re: [Qt-qml] ListView with "spacer" > > Thanks I was confused by the docs: > Attached Properties > ... > * view : ListView > > But when you click on view, it then says: > ListView.view : ListView > > How does the ListView.view scheme work?I would think I would only need "view" > and that "ListView.view" would be an anonymous list view, and not know to use > my delegate? > > Thanks. > > ________________________________ > From: Juha Turunen <[email protected]> > To: [email protected] > Sent: Wednesday, August 24, 2011 5:24 AM > Subject: Re: [Qt-qml] ListView with "spacer" > > On Wed, Aug 24, 2011 at 7:18 AM, Jason H <[email protected]> wrote: > > > But when I set > > height:view.contentHeight > > I get an error "can't find view" even though it is an attached property in > > the docs. > > The attached property is "ListView.view" not "view". > > Juha > _______________________________________________ > Qt-qml mailing list > [email protected] > http://lists.qt.nokia.com/mailman/listinfo/qt-qml > _______________________________________________ > Qt-qml mailing list > [email protected] > http://lists.qt.nokia.com/mailman/listinfo/qt-qml > > > _______________________________________________ > Qt-qml mailing list > [email protected] > http://lists.qt.nokia.com/mailman/listinfo/qt-qml
_______________________________________________ Qt-qml mailing list [email protected] http://lists.qt.nokia.com/mailman/listinfo/qt-qml
