3
RowLayout에 RowLayout이 있습니다. RowLayout은 예상대로 배치됩니다. 창 크기를 조정하는 경우에도 마찬가지입니다. 창문 전체 columnLayout도보다 작은 경우에도ListView가 예상대로 레이아웃에 배치되지 않았습니다.
을 (두 번째 이미지 참조) 그러나 나는 (수평) ListView에 의해 RowLayout를 교체하면 내가 기대하는 것처럼,이 ListView에이 위치하지 않습니다.
을 그리고 창은 파란색 사각형 '작은에'얻는 경우에 첫 번째 예는 달리 ListView에 '로 이동':이가 RowLayout와 예처럼 동작하지만 ListView에 더 높은 위치 기대 :
어떻게 ListView를 가진 첫 번째 예제의 동작을 달성 할 수 있습니까?
소스
import QtQuick 2.0
import QtQuick.Layouts 1.1
Rectangle {
width: 360
height: 360
ColumnLayout {
anchors.fill: parent
anchors.margins: 20
Item {
Layout.fillHeight: true
}
/*
ListView {
Layout.fillHeight: true
Layout.fillWidth: true
orientation: ListView.Horizontal
spacing: 5
model: 3
delegate: Rectangle {
width: 50
height: 50
color: "red"
}
}
*/
RowLayout {
Layout.fillHeight: true
Layout.fillWidth: true
Rectangle {
width: 50
height: 50
color: "red"
}
Rectangle {
width: 50
height: 50
color: "red"
}
Rectangle {
width: 50
height: 50
color: "red"
}
}
Item {
Layout.fillHeight: true
}
Rectangle {
width: 50
height: 50
color: "blue"
}
}
}
이이 구체적인 예를 들어 작동합니다. 그러나 델리게이트의 높이가 동적 인 경우에는 어떻게해야할까요? ListView 높이의 하드 코드 된 값이 제대로 작동하지 않습니다 ... Layout.fillHeight를 시도했기 때문에 그랬습니다 : true – avb
'ListView''height' 속성을'childrenRect.height' -'height : childrenRect.height'로 설정했습니다. 각 위임 인스턴스에 구체적이고 긍정적 인 'height' 속성이 있으면 (사용 사례와 마찬가지로)'childrenRect.height '가 작동하는 것 같습니다. –