Forums

OverviewFelgo 2 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.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support