[SOLVED] Height of ListView delegate(multidelegate)
-
wrote on 28 Mar 2012, 19:30 last edited by
How can I set the height of multiDelegate? The height of multiDelegate depends on type of delegate (imgDelegate or txtDelegate)
Below my delegate code (MultiDelegate.qml)
@
import QtQuick 1.1Item {
id: multiDelegate
width: multiDelegate.ListView.view.widthComponent {
id: imgDelegateImage { id: img source: value fillMode: Image.PreserveAspectFit asynchronous: true }
}
Component {
id: txtDelegateText { id: txt text: value verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter wrapMode: Text.Wrap }
}
Loader {
id: itemDisplay
anchors.fill: parent;
anchors.topMargin: 2
anchors.bottomMargin: 2
sourceComponent: type ? imgDelegate : txtDelegate
}}@
-
wrote on 30 Mar 2012, 20:01 last edited by
Hello,
Try following:
- Set @ multiDelegate.height: itemDisplay.height @
According to documentation:
bq. If an explicit size is not specified for the Loader, the Loader is automatically resized to the size of the loaded item once the component is loaded. -
wrote on 1 Apr 2012, 15:44 last edited by
I tried following
@
import QtQuick 1.1Item {
id: multiDelegate
width: multiDelegate.ListView.view.width
height: itemDisplay.height
@but it didn't work. I got following error
@
MainPage.qml QML Item: Binding loop detected for property "height"
MultiDelegate.qml QML Loader: Possible anchor loop detected on fill.
MultiDelegate.qml QML Loader: Possible anchor loop detected on fill.
MainPage.qml QML Item: Binding loop detected for property "height"
MainPage.qml QML Item: Binding loop detected for property "height"
MultiDelegate.qml QML Loader: Possible anchor loop detected on fill.
@ -
wrote on 1 Apr 2012, 18:41 last edited by
Problem solved
I modified Loader element like this
@
Loader {
id: itemDisplay
sourceComponent: type ? imgDelegate : txtDelegate
}
@
1/4