Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. PhotoAlbumViewer - Data Duplication
Forum Updated to NodeBB v4.3 + New Features

PhotoAlbumViewer - Data Duplication

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 2 Posters 1.0k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anas A. Ismail
    wrote on last edited by Anas A. Ismail
    #1

    I was extending one of qt examples, it's simply loading images from local disk, then show them in albums view ..
    I make something like this,

    main.qml
    ListModel{
    id: photosModel
    }

    // File dialog for selecting image file from local file system
    FileDialog {
        id: fileDialog
        title: "Choose a folder"
        nameFilters: [ "Image files (*.png *.jpg *.jpeg)"]
        selectFolder: true
        onAccepted: {
            mainWindow.editMode = false
            photosModel.append({folder: fileDialog.folder + "/"})
        }
    }
    
    function getFolderUrl(){
        return fileDialog.fileUrl + "/"
    }
    
    DelegateModel { id: albumVisualModel; model: photosModel; delegate: AlbumDelegate {} }
    
    GridView {
        id: albumView; width: parent.width; height: parent.height; cellWidth: 210; cellHeight: 220
        model: albumVisualModel.parts.album; visible: albumsShade.opacity != 1.0
    }
    

    AlbumDelegate.qml

    Item {
    Package.name: 'album'
    id: albumWrapper; width: 210; height: 220

            DelegateModel {
                id: visualModel; delegate: ImageDelegate { }
                model: FilesModel { id: rssModel; folder: mainWindow.getFolderUrl()}
            }
    

    ....
    }

    ImageDelegate.qml
    .....
    Image {
    id: originalImage; antialiasing: true; asynchronous: true
    source: "image://provider/"+ rssModel.folder +fileName;cache: false;
    fillMode: Image.PreserveAspectFit; width: photoWrapper.width; height: photoWrapper.height
    }
    ....
    }

    The main problem is that when I load more than one folder I got all folders point to the same url like this image, any help in this ?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      If you want to show the content of several folders, you should build a list of these folders and use that to feed your DelegateModel

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      A 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        If you want to show the content of several folders, you should build a list of these folders and use that to feed your DelegateModel

        A Offline
        A Offline
        Anas A. Ismail
        wrote on last edited by
        #3

        @SGaist Do you mean something like ListModel of FolderListModel, right that ?
        may you show me some starter code for this if it's possible ?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Use the same technique you have with your photosModel

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • A Offline
            A Offline
            Anas A. Ismail
            wrote on last edited by
            #5

            Thanks for your help,
            The problem was that the model was always referring to the same directory because of using this method

            function getFolderUrl(){
            return fileDialog.fileUrl + "/"
            }
            I fixed this by setting the directory for each instance like this.
            DelegateModel { id: albumVisualModel; model: photosModel; delegate: AlbumDelegate {folderURL: model.folder
            } }

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Good !

              Since you have it working now, please mark the thread as solved using the "Topic Tool" button so other forum users may know a solution has been found :)

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved