I’m trying to implement an application where a user selects an image via the UserImage tool and that image can be displayed on another list page. I used this code to get the image
UserImage {
id: userImage
property string iconFontName: Theme.iconFont.name
width: dp(72)
height: width
placeholderImage: "\uf007" // user
source: ""
editable: true
editBackgroundColor: Theme.tintColor
property bool shownEditPhotoDialog: false
onEditClicked: {
// We do not have camera feature on desktop yet, so just show file dialog
if (system.desktopPlatform) {
nativeUtils.displayImagePicker(qsTr("Choose Image"))
}
else {
// Probably better use a QML styled dialog?
shownEditPhotoDialog = true
nativeUtils.displayAlertSheet("", ["Choose Photo", "Take Photo", "Reset Photo"], true)
}
}
Connections {
target: nativeUtils
onAlertSheetFinished: {
if (userImage.shownEditPhotoDialog) {
if (index == 0)
nativeUtils.displayImagePicker(qsTr("Choose Image")) // Choose image
else if (index == 1)
nativeUtils.displayCameraPicker("Take Photo") // Take from Camera
else if (index == 2)
userImage.source = "" // Reset
userImage.shownEditPhotoDialog = false
}
}
onImagePickerFinished: {
console.debug("Image picker finished with path:", path)
if(accepted)
userImage.source = Qt.resolvedUrl(path)
}
onCameraPickerFinished: {
console.debug("Camera picker finished with path:", path)
if(accepted)
userImage.source = Qt.resolvedUrl(path)
}
}
} // User Image
and declared the property name as
property alias image: Qt.resolvedUrl(path)
However when I call the image property, nothing happens. Is there anything am missing?