qt - How to set a image source outside Component -


i have image showing in dialog in qml app, , want able change image later on using onclicked, pass function check if variable want in new source url 1 of them want.

i've tried using image.source = "newurl" no go. id of component image in, , dialog like: id.source = "neurl" - no go.

how do that?

edit: added more code; both function , listitm used click. image web image, , want have conncecteduser value (which user name) inside url.

here related code:

// check if users user, , if; show skin function checkcurrentuser(currentuser) {     console.debug('debug: check user "'+currentuser+'" if user.')      if (currentuser == "ingen online") {         currentuser = "notch" // reset currentuser if pushed earlier         console.debug('debug: not real user. showing '+currentuser+' instead')         image.source = "http://blabla"+currentuser+"yesyes"     }     else {         console.debug('debug: real user.')         image.source = "http://blabla"+currentuser+"yesyes"     }     return "http://blabla"+currentuser+"yesyes"" }              // dialog want show 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)                      }                  }                 }       // , list containting each link, on click should show 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) }                 } 

i not sure if understood question correctly, give try:

   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                                                  }                  }               }     } 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -