QML 앱의 대화 상자에 이미지가 표시되고 나중에 onClicked를 사용하여 해당 이미지를 변경할 수있게하고 싶습니다. 새 원본 URL에서 원하는 변수 중 하나는 원하는 것입니다.이미지 소스를 외부에 설정하는 방법
나는 그냥 사용하지 않는 Image.source = "NEWURL"을 사용해 보았습니다. 또한 이미지가있는 구성 요소의 ID 및 대화 상자는 다음과 같습니다. id.source = "neurl"- no go.
어떻게하면됩니까?
편집 : 추가 코드; 둘 다 함수를 누른 다음 listitm 클릭하는 데 사용됩니다. 이미지는 웹 이미지이며 url 내부에 conncectedUser 값 (사용자 이름)을 갖고 싶습니다. 여기
는 모든 관련 코드 :// Check if users is really a user, and if; show skin
function checkCurrentUser(currentUser) {
console.debug('Debug: Check user "'+currentUser+'" if actually a user.')
if (currentUser == "Ingen online") {
currentUser = "Notch" // reset currentUser if pushed earlier
console.debug('Debug: It was not a real user. Showing '+currentUser+' instead')
Image.source = "http://blabla"+currentUser+"yesyes"
}
else {
console.debug('Debug: It was a real user.')
Image.source = "http://blabla"+currentUser+"yesyes"
}
return "http://blabla"+currentUser+"yesyes""
}
// the dialog I want to show with a image
Component {
id: userDialog
Dialog {
id: dialogueUser
title: i18n.tr("Image")
Image {
id: usersSkin
fillMode: Image.PreserveAspectFit
source: "URL"
sourceSize.height: 1200
}
Button {
text: i18n.tr("Close")
color: "red"
onClicked: PopupUtils.close(dialogueUser)
}
}
}
// and then the list containting each link, which on click should show the user image
ListView {
id: userList
width: parent.width
height: units.gu(5)
model: msmData
delegate: ListItem.Standard {
text: connectedUser
onClicked: {
console.debug('Debug: User clicked "'+connectedUser+'"')
checkCurrentUser(connectedUser)
PopupUtils.open(userDialog, userList)
}
}
header: ListItem.Header { text: i18n.tr("Connected Users") }
section.property: "type"
section.criteria: ViewSection.FullString
section.delegate: ListItem.Header { text: i18n.tr(section) }
}
'ImageSource = "NEWURL"을 사용해 보았습니다. 이유를 설명해주세요. –
안녕하세요, 이미지가 표시되지 않습니다. –