I have a problem where items disappear in my ListView which is in a popup when I use LayoutMirroring.
Sometimes the last item disappears and sometimes the second last item, depending on the LayoutMirroring.
The bug disappears when I comment out the lines which set the contentWidth and contentHeight.
I do not understand why this is happening, does anyone have an explanation?
The code example:
import QtQuick 2.15
import QtQml 2.15
import QtQuick.Window 2.14
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
Window {
id: root
property bool mirrorLayout: false
width: 800
height: 600
LayoutMirroring.enabled: mirrorLayout
LayoutMirroring.childrenInherit: mirrorLayout
ColumnLayout {
RowLayout {
LayoutMirroring.enabled: false
Button {
text: "Open Popup"
onClicked: popup.open()
}
Button {
text: "Mirror Layout"
onClicked: mirrorLayout = !mirrorLayout
}
Text {
text: "IsMirrored:", mirrorLayout
}
}
RowLayout {
Repeater {
model: 5
delegate: Rectangle {
color: "red"
opacity: (5 - index) / 5
width: 40
height: 40
Text {
text: index + 1
anchors.centerIn: parent
}
}
}
}
}
Popup {
id: popup
width: 400
height: 400
modal: true
focus: true
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
contentItem: ListView {
id: contentList
implicitHeight: contentHeight
implicitWidth: contentWidth
contentHeight: contentItem.childrenRect.height
contentWidth: contentItem.childrenRect.width
orientation: ListView.Horizontal
interactive: orientation === ListView.Vertical ? contentHeight > height : contentWidth > width
clip: interactive
LayoutMirroring.enabled: root.mirrorLayout
LayoutMirroring.childrenInherit: root.mirrorLayout
model: 5
delegate: Rectangle {
color: "red"
opacity: (5 - index) / 5
width: 40
height: 40
Text {
text: index + 1
anchors.centerIn: parent
}
}
}
}
}
The bug disappears when I comment out the contentWidth line in the ListView, but I do not really understand why
mighterYEP is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.