Created
February 8, 2014 18:57
-
-
Save Kakadu/8888361 to your computer and use it in GitHub Desktop.
ListView for buttons with custom onclick events. In this implementation button onclick handler is placed in model near to useful properties of button. I don't want to place them far away of button descriptions because it breaks readability.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import QtQuick 2.0 | |
Rectangle { | |
id: root | |
anchors { left: parent.left; right: parent.right } | |
height: 30 | |
color: "gray" | |
radius: 15 | |
border.width: 1 | |
property alias title: textItem.text | |
property alias itemColor: root.color | |
signal listItemClick() | |
Text { | |
id: textItem | |
text: "" | |
anchors.centerIn: parent | |
} | |
MouseArea { | |
anchors.fill: parent | |
onClicked: listItemClick(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import QtQuick 2.0 | |
Rectangle{ | |
width:500 | |
height:500 | |
ListView { | |
width: parent.width | |
height: parent.height | |
clip: true | |
model: mainModel | |
spacing: 3 | |
} | |
VisualItemModel { | |
id: mainModel | |
ListItem { | |
title: "asd" | |
color: "lightgray" | |
onListItemClick: console.log("Evaluate Fast Fourier transformation") | |
} | |
ListItem { | |
title: "qwer" | |
color: "green" | |
onListItemClick: console.log("Launch Nuclear Weapon") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment