I am using Qt/QML. on my touch screen, I have a side drawer that enables when user touches the menu button and it brings a side panel to the screen. My ListView holds a list model which has 7 ListElement in it. Which further bring users to separate setting pages. I want one of the List Element be visible based on a bool value. In short I like to make the visibility conditional for that List Element. How can I do it?
model: ListModel {
ListElement { title: "abcd"; iconsource: "qrc:/qml/images/abcd.png"; source: "qrc:/qml/abcd.qml"; ftoption: 243; visible: true}
ListElement { title: "xyz"; iconsource: "qrc:/qml/images/xyz.png"; source: "qrc:/qml/xyz.qml"; ftoption: 243; visible: true}
ListElement { title: "pqr"; iconsource: "qrc:/qml/images/pqr.png"; source: "qrc:/qml/pqr.qml"; ftoption: 243; visible: true}
}
delegate: ItemDelegate {
id: menu_item
width: parent.width
height: Style.footerHeight
visible: (model.title === "pqr") ? menuVisibility : true
Timer {
interval: 5000; running: true; repeat: true
onTriggered: {(model.title === "pqr") ? model.visible = menuVisibility : model.visible = true}
}
Just add
visible(can be other name though) role in your model.Simple example:
(You can drop the
Timerit is just for illustration)