PDA

View Full Version : how to add multiple strings into the spinner



vinayaka
19th July 2011, 06:48
created an alarm using qml. we can't add 'am' and 'pm' to the last spinner. how can we add it?


import Qt 4.7
import "content"

Rectangle {

width:238; height:197
property int hr
property int min
property int am
signal titleBarClicked(int hr,int min,int am)


Row {
y: 0; x:0; spacing: 20


Image {
id: image1
source: "content/spinner-bgc.png"

}

}



Row {
y: 0; x: 7; spacing:20

Spinner {
id: spinner
width:70; height: 197
focus: false
model: 13
itemHeight: 30
delegate: Text { font.pixelSize: 25; text: index; height: 30;font.bold:true;}


}
}
Row {
y: 0; x:77; spacing: 20


Image {
id: image2
source: "content/spinner-bgc.png"
}

}






Row {
y: 0; x:84; spacing:20

Spinner {
id: spinner2
width:70; height: 197
focus: true
model: 60
itemHeight: 30
delegate: Text { font.pixelSize: 25; text: index; height: 30;font.bold:true;}
}



}
Row {
y: 0; x:154; spacing: 20


Image {
id: image3
source: "content/spinner-bgc.png"
}

}
Row {
y: 0; x:161; spacing:20

Spinner {
id: spinner3
width:70; height: 197
focus: true
model: name
itemHeight: 30

delegate: Text {font.pixelSize: 25; text: "PM"; height:30;font.bold:true;}
Text {
id: name
text: ""
}





}





}
Row {
y: 0; x:231; spacing: 20


Image {
id: image4
source: "content/spinner-bgc.png"
}

}
Connections {
target:titleBarClicked(spinner.currentIndex,spinne r2.currentIndex,spinner3.currentIndex)
}


}

MarekR22
22nd July 2011, 10:11
it is quite simple just think:

Spinner {
id: spinner3
width:70; height: 197
focus: true
model: 2
itemHeight: 30

delegate: Text {
font.pixelSize: 25
text: index==0?"AM":"PM"
height:30
font.bold:true;
}
}

vinayaka
27th July 2011, 11:08
how can add more than 2strings to spinner

MarekR22
27th July 2011, 12:55
http://doc.qt.nokia.com/latest/qml-visualdatamodel.html