Results 1 to 5 of 5

Thread: load a specific image for each item of listview

  1. #1
    Join Date
    Jan 2016
    Posts
    54
    Thanks
    7
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default load a specific image for each item of listview

    Hiii everyOne,

    I have a listView that contains some elements :
    Qt Code:
    1. ListView {
    2. model: menuModel
    3. delegate: categoryDelegate
    4. ...
    5. }
    6. ListModel {
    7. id: menuModel
    8. ListElement {
    9. ...
    10. Component {
    11. id: categoryDelegate
    12. Column {
    13. Rectangle {
    14. id: categoryItem
    15. ...
    16. Image {
    17. id: img
    18. ...
    19. }
    To copy to clipboard, switch view to plain text mode 

    I want for each element (each rectangle) load a specific image
    The code above load the same image for each element

    Cheers,

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: load a specific image for each item of listview

    Put the image URL into the model, let the delegate get the data from the model just like any other data.

    Cheers,
    _

  3. #3
    Join Date
    Dec 2015
    Location
    Austria
    Posts
    23
    Thanks
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Windows Android

    Default Re: load a specific image for each item of listview

    For Detail Information, here is what you need
    https://wiki.qt.io/How_To_Use_QML_ListView

  4. #4
    Join Date
    Jan 2016
    Posts
    54
    Thanks
    7
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: load a specific image for each item of listview

    Thanks, That's right

    I want for each image modify : sourceSize ???

    Cheers,

  5. #5
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: load a specific image for each item of listview

    Again, just extend the model
    You might need to split the size in a sourceWidth and sourceHeight property

    Cheers,
    _

Similar Threads

  1. Load more items to listview
    By matsukan in forum Qt Quick
    Replies: 1
    Last Post: 14th November 2012, 23:48
  2. I want to edit listview's item using contextmenu. How to?
    By melody:p in forum Qt Programming
    Replies: 3
    Last Post: 6th August 2012, 01:40
  3. Replies: 2
    Last Post: 3rd August 2012, 11:05
  4. listview item focusing
    By addu in forum Qt Programming
    Replies: 7
    Last Post: 18th August 2009, 07:07
  5. getting clicked item from listview
    By addu in forum Qt Programming
    Replies: 6
    Last Post: 14th May 2009, 10:33

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.