see this code:
import QtQuick 2.0
import QtQuick.Controls 1.1
Item {
width: 100; height: 100
Component.onCompleted: {
for (var i = 0; i < 5; i++){
repeater.append({"name": i})
}
}
Row {
Repeater {
model: ListModel {
id: repeater
}
Button {
id:dokme
y:20
width:20
height:20
Text{
text:name
anchors.centerIn: parent
}
onClicked: {
rang(this)
}
function rang(e){
this.iconSource = "b.gif"
}
}
}
}
}
import QtQuick 2.0
import QtQuick.Controls 1.1
Item {
width: 100; height: 100
Component.onCompleted: {
for (var i = 0; i < 5; i++){
repeater.append({"name": i})
}
}
Row {
Repeater {
model: ListModel {
id: repeater
}
Button {
id:dokme
y:20
width:20
height:20
Text{
text:name
anchors.centerIn: parent
}
onClicked: {
rang(this)
}
function rang(e){
this.iconSource = "b.gif"
}
}
}
}
}
To copy to clipboard, switch view to plain text mode
see this code.
When the button is clicked.
Button color changes.
But not like that image.
Added after 1 24 minutes:
The problem was solved:
import QtQuick 2.0
import QtQuick.Controls 1.1
Item {
width: 100; height: 100
Component.onCompleted: {
for (var i = 0; i < 5; i++){
repeater.append({"name": i})
}
}
Row {
Repeater {
model: ListModel {
id: repeater
}
Button {
id:dokme
y:20
width:20
height:20
Text{
id:man
color: activeFocus ? "red" : "#000000"
text:activeFocus ? "<b>"+name+"</b>" : name
anchors.centerIn: parent
}
onClicked: {
man.forceActiveFocus();
}
}
}
}
}
import QtQuick 2.0
import QtQuick.Controls 1.1
Item {
width: 100; height: 100
Component.onCompleted: {
for (var i = 0; i < 5; i++){
repeater.append({"name": i})
}
}
Row {
Repeater {
model: ListModel {
id: repeater
}
Button {
id:dokme
y:20
width:20
height:20
Text{
id:man
color: activeFocus ? "red" : "#000000"
text:activeFocus ? "<b>"+name+"</b>" : name
anchors.centerIn: parent
}
onClicked: {
man.forceActiveFocus();
}
}
}
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks