Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to set a image source outside Component
    primarykey
    data
    text
    <p>I have a image showing up in a Dialog in my QML app, and I want to be able to change that image later on using onClicked, which I pass by a function to check if the variable I want in the new source URL is one of them I want.</p> <p>I've tried just by using Image.source = "NEWURL" which is a no go. Also the id of the component the image is in, and the dialog like: id.source = "neurl" - no go.</p> <p>How do I do that?</p> <p>EDIT: Added more code; both the function and then listitm used to click. The image is a web image, and I want to have the conncectedUser value (which is a user name) inside the url.</p> <p>Here is all the related code:</p> <pre><code>// 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) } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload