Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Forums

OverviewFelgo 3 Support (Qt 5) › Image declaration

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #20196

    Daniel Muriithi

    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?

    #20267

    Günther
    Felgo Team

    A property alias can only reference other properties, and not hold expressions or bindings. 😉

     

    #20530

    Daniel Muriithi

    What can I do to hold the image binding?

Viewing 3 posts - 1 through 3 (of 3 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded