PDA

View Full Version : qml slot (funtion) value cannot access out side the function



m.azeemanwar
15th December 2011, 06:54
hi , please help me i receive a slot (function) in qml file when but function value cant access out side function as playername is class variable.
but it return empty string my code is with out put .


import QtQuick 1.0
Rectangle {
id: container
property string playername: ""
function playerinfo(str,str1,str2,str3){
console.log(str,str1,str2,str3)
console.log("i m comming from c++ file other player name is "+str1)
container.playername= str1
console.log("i am in functoin value displayed "+container.playername)
}
function hide() {
container.opacity = 0;
}

width: dialogText.width + 20
height: dialogText.height + 20
opacity: 0

Text {
id: dialogText
anchors.centerIn: parent
color:"red"
text: "Dummy"
}

MouseArea {
anchors.fill: parent
onClicked:{
console.log(" outside the function player name on clicked is empty " +container.playername)
hide();
}
}
}

output of this file is >>>>>>>>>>>>>>>>

i m comming from c++ file other player name is azeem
i am in functoin value displayed azeem
outside the function player name on clicked is empty