Skip to content

Instantly share code, notes, and snippets.

@Kakadu
Created June 4, 2014 08:20
Show Gist options
  • Save Kakadu/c273daf2bf05cc6f25a8 to your computer and use it in GitHub Desktop.
Save Kakadu/c273daf2bf05cc6f25a8 to your computer and use it in GitHub Desktop.
QtQuick attached signal Add example
import QtQuick 2.1
Rectangle {
width: 800; height: 600
ListModel {
id: nameModel
ListElement { name: "Alice" }
ListElement { name: "Bob" }
ListElement { name: "Jane" }
ListElement { name: "Harry" }
ListElement { name: "Wendy" }
}
Rectangle {
id: nameDelegate
Text {
text: model.name;
font.pixelSize: 24
}
ListView.onAdd: {
console.log("onAdd");
}
}
ListView {
anchors.fill: parent
clip: true
model: nameModel
delegate: Rectangle {
height: 30
Text {
text: model.name;
font.pixelSize: 24
}
ListView.onAdd: {
//console.log("onAdd");
if (ListView.view.count>=10) ListView.view.currentIndex = 10;
}
}
header: bannercomponent
footer: Rectangle {
width: parent.width; height: 30;
gradient: clubcolors
}
highlight: Rectangle {
width: parent.width
color: "lightgray"
}
}
Component { //instantiated when header is processed
id: bannercomponent
Rectangle {
id: banner
width: parent.width; height: 50
gradient: clubcolors
border {color: "#9EDDF2"; width: 2}
Text {
anchors.centerIn: parent
text: "Club Members"
font.pixelSize: 32
}
}
}
Gradient {
id: clubcolors
GradientStop { position: 0.0; color: "#8EE2FE"}
GradientStop { position: 0.66; color: "#7ED2EE"}
}
Component.onCompleted: {
nameModel.append({ name: "1" });
nameModel.append({ name: "2" });
nameModel.append({ name: "3" });
nameModel.append({ name: "4" });
nameModel.append({ name: "5" });
nameModel.append({ name: "6" });
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment