Results 1 to 7 of 7

Thread: PhotoAlbumViewer - Prevent Data Duplication

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2015
    Posts
    8
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default PhotoAlbumViewer - Prevent Data Duplication

    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
    Qt Code:
    1. ListModel{
    2. id: photosModel
    3. }
    4. // File dialog for selecting image file from local file system
    5. FileDialog {
    6. id: fileDialog
    7. title: "Choose a folder"
    8. nameFilters: [ "Image files (*.png *.jpg *.jpeg)"]
    9. selectFolder: true
    10. onAccepted: {
    11. mainWindow.editMode = false
    12. photosModel.append({folder: fileDialog.folder + "/"})
    13. }
    14. }
    15.  
    16. function getFolderUrl(){
    17. return fileDialog.fileUrl + "/"
    18. }
    19.  
    20. DelegateModel { id: albumVisualModel; model: photosModel; delegate: AlbumDelegate {} }
    21.  
    22. GridView {
    23. id: albumView; width: parent.width; height: parent.height; cellWidth: 210; cellHeight: 220
    24. model: albumVisualModel.parts.album; visible: albumsShade.opacity != 1.0
    25. }
    To copy to clipboard, switch view to plain text mode 
    AlbumDelegate.qml
    Qt Code:
    1. Item {
    2. Package.name: 'album'
    3. id: albumWrapper; width: 210; height: 220
    4.  
    5. DelegateModel {
    6. id: visualModel; delegate: ImageDelegate { }
    7. model: FilesModel { id: rssModel; folder: mainWindow.getFolderUrl()}
    8. }
    9. ....
    10. }
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. ImageDelegate.qml
    2. .....
    3. Image {
    4. id: originalImage; antialiasing: true; asynchronous: true
    5. source: "image://provider/"+ rssModel.folder +fileName;cache: false;
    6. fillMode: Image.PreserveAspectFit; width: photoWrapper.width; height: photoWrapper.height
    7. }
    8. ....
    9. }
    To copy to clipboard, switch view to plain text mode 
    The main problem is that when I load more than one folder I got all folders point to the same url, any help in this ?
    Last edited by anda_skoa; 12th November 2015 at 08:11. Reason: missing [code] tags

Similar Threads

  1. prevent Window Moving?
    By maybnxtseasn in forum Qt Programming
    Replies: 13
    Last Post: 12th March 2012, 16:40
  2. prevent drop in QTreeWidget
    By GrahamLabdon in forum Newbie
    Replies: 1
    Last Post: 27th May 2011, 20:24
  3. Replies: 1
    Last Post: 17th August 2010, 02:19
  4. How to prevent QListWidget from itemdragging
    By Arthur in forum Qt Programming
    Replies: 6
    Last Post: 17th April 2006, 21:41
  5. Prevent from resizing a QMainWindow
    By Flier in forum Qt Tools
    Replies: 5
    Last Post: 14th April 2006, 17:11

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.