2013-05-09 2 views
0

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) } 
       } 
+0

'ImageSource = "NEWURL"을 사용해 보았습니다. 이유를 설명해주세요. –

+0

안녕하세요, 이미지가 표시되지 않습니다. –

답변

0

고지를 이미지 URL에서 변수를 재설정 한 다음 대화 상자를 표시하면됩니다. 지금 일하고있어.

0

내가 제대로 질문을 이해하면 잘 모르겠지만, 나는 그것을 시도 줄 것이다 : 내가 마지막으로했던 것은

Component 
    { 
      id: userDialog 
      Dialog 
      { 
       property int sourceState : 1 
       id: dialogueUser 
       title: i18n.tr("Image") 
       Image 
       { 
        id: usersSkin 
        fillMode: Image.PreserveAspectFit 
        source: 1 == sourceState ? "OLDURL" : "NEWURL" 
        sourceSize.height: 1200 
       } 

       Button 
       { 
        text: i18n.tr("Close") 
        color: "red" 
        onClicked: 
        { 
         PopupUtils.close(dialogueUser) 
         dialogueUser.sourceState = 0        
        } 
       } 
       } 
    } 
+0

감사합니다.하지만 위임 된 XML 목록 항목에서 오는 사용자 클릭을 기반으로 새 URL에 varible을 푸시해야합니다. –

관련 문제