Results 1 to 7 of 7

Thread: How to add Icons to items using QAbstractListModel in QListView

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #7
    Join Date
    Dec 2010
    Location
    Ukraine, Kharkiv
    Posts
    17
    Thanks
    3
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Cool Re: How to add Icons to items using QAbstractListModel in QListView

    Qt Code:
    1. ui.contentListView->setViewMode(QListView::IconMode);
    2. iStandardModel = new QStandardItemModel(this);
    3.  
    4. QList<QStandardItem*> *items = new QList<QStandardItem*> ();
    5.  
    6. QString qs = ui.searchLineEdit->text();
    7.  
    8. *items = getItemsToDisplay(qs);
    9.  
    10. iStandardModel->appendColumn(*items);
    11.  
    12. //Setting the icon size
    13. ui.contentListView->setIconSize(QSize(128, 128));
    14. //Setting the model
    15. ui.contentListView->setModel(iStandardModel);
    To copy to clipboard, switch view to plain text mode 

    In ui_GUIClass.h:
    Qt Code:
    1. public:
    2. QListView *contentListView;
    To copy to clipboard, switch view to plain text mode 

    In GUIClass.h:
    Qt Code:
    1. public:
    2. QStandardItemModel* iStandardModel;
    To copy to clipboard, switch view to plain text mode 

    The result is in attached sample.jpg.
    Hope, this helps.
    Attached Images Attached Images

Similar Threads

  1. QListView with icons on top of the text, not at the left
    By vfernandez in forum Qt Programming
    Replies: 7
    Last Post: 19th February 2009, 04:19
  2. how to get item's text or path from QListVIew
    By Mystical Groovy in forum Qt Programming
    Replies: 4
    Last Post: 5th September 2008, 01:25
  3. Navigate through qlistview items with shortcuts
    By jiveaxe in forum Qt Programming
    Replies: 4
    Last Post: 10th January 2008, 11:28
  4. Items in QListView should sort on Header Click
    By vinnu in forum Qt Programming
    Replies: 14
    Last Post: 10th November 2006, 12:49
  5. moving Qlistview items
    By :db:sStrong in forum Qt Programming
    Replies: 0
    Last Post: 21st February 2006, 12:25

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.