Forums

OverviewFelgo 2 Support (Qt 5) › Getting path from ImagePicker

Tagged: 

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #21480

    Felgo User

    Hi,

    I am using ImagePicker to choose an image and get the image path to pass it to a QQuickImageProvider. I have the following code:

    import Felgo 3.0
    import QtQuick 2.11
    import QtQuick.Dialogs 1.2
    
    App {
        id: app
    
        NavigationStack {
    
            Page {
                title: qsTr("Image Converter")
    
                IconButton {
                    id: enlarge
                    visible: false
                    color: "blue"
                    icon: IconType.arrowsalt
                    anchors.baseline: button.baseline
                    anchors.right: button.left
    
                    onClicked: {
                        PictureViewer.show(app, image.source)
                    }
                }
    
                AppButton {
                    id: button
    
                    anchors.horizontalCenter: imageViewer.horizontalCenter
                    anchors.bottom: imageViewer.top
                    text: "Choose Image"
                    onClicked: {
                        nativeUtils.displayImagePicker("Choose the Friend's Image")
                    }
                }
    
                Rectangle {
                    id: imageViewer
                    width: 250
                    height: 250
                    anchors.centerIn: parent
    
                    AppImage {
                        id: image
                        onStatusChanged: if (image.status == Image.Ready)
                                             enlarge.visible = true
                        anchors.fill: parent
                        width: 250
                        height: 250
                        autoTransform: true
                        fillMode: Image.PreserveAspectFit
                    }
                }
    
                Connections {
                    target: nativeUtils
    
                    onImagePickerFinished: {
                        if (accepted) {
                            var path
    
                            image.source = "image://pix/path"
    
                            console.log("The path in main.qml: ", path)
                        }
                    }
                }
            }
        }
    }
    

    How can I get the image path from the ImagePicker?

    Thank you for your help.

    #21494

    Alex
    Felgo Team
Viewing 2 posts - 1 through 2 (of 2 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