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

Forums

OverviewFelgo 3 Support (Qt 5) › ImagePicker change selection on new image pressed

Tagged: 

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

    Edward

    Hey Guys

    I’m using the ImagePicker (for it’s obvious reasons); However I only want 1 image selected at a time (maximumNumberOfSelection: 1) perfect!

     

    However I want, if you already have 1 image selected and then ‘re-select’ a different image you want to use instead, that it will change the selection and remove the other.

    I’m having some trouble creating this feature, I have tried things such as:

     

     

    onSelectionChanged: if(selectedCount === 1){imagePicker.clearSelection()}  

     

    OR

     

    property var selectionArray: []
    
    onSelectionChanged: selectionArray.length === 1 ? selectionArray = [] && selectionArray.push(selection.toString()) : selectionArray.push(selection.toString())

     

     

    Amongst other variations or toying with the ‘onSelectionChanged’ and ‘onSelectionCountChanged’ but cannot seem to get it to clear when a new image is tapped. Is there any suggestions on how to go about this?

    #24460

    Alex
    Felgo Team

    Hi,

    with the current API, this will not be possible. I would suggest to show the user the current selection count instead (e.g. 0/1 –> 1/1), which gives him a clear hint that in order to select a new image, he has to unselect the current again, to make “room” for a new selection. Here is an example for that.

    import Felgo 3.0
    import QtQuick 2.8
    
    App {
      NavigationStack {
        Page {
          id: page
          title: qsTr("Choose Photos")
    
          // right bar item to accept selection
          rightBarItem: TextButtonBarItem {
            text: imagePicker.selectedCount + "/" + imagePicker.maximumNumberOfSelection + " Next"
            enabled: imagePicker.selectedCount > 0
            opacity: enabled ? 1 : 0.5
    
            // your app will probably pop the photo selection page from the stack to move on
            // this example only logs the selected photos
            onClicked: console.debug("SELECTED:", JSON.stringify(imagePicker.selection))
          }
          leftBarItem: TextButtonBarItem {
            text: "Cancel"
          }
    
          // image picker view for photo selection
          ImagePicker {
            id: imagePicker
            anchors.fill: parent
            maximumNumberOfSelection: 1
          }
        }
      }
    }
    

    I will propose an extension of the API to allow for your use case, so we might add this in one of the next updates.

    Best,
    Alex

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