Results 1 to 2 of 2

Thread: QListView

  1. #1
    Join Date
    Jan 2020
    Posts
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default QListView

    Hi,
    I tried adding an icon with a text to QListView.
    it shows the icon on top of the text. I want it to show it on next to each other like <Icon><Text>
    how to do it?
    Here is below my code:

    Qt Code:
    1. // String List Model 2
    2. sim2 = new QStandardItemModel;
    3. // List View 2
    4. lv2 = new QListView;
    5. lv2->setModel(sim2);
    6. lv2->setViewMode(QListView::IconMode);
    7. lv2->setFlow(QListView::TopToBottom);
    8. sim2->appendRow(new QStandardItem(QIcon(":/Images/LEDOn.jpg"), "Test1"));
    9. sim2->appendRow(new QStandardItem(QIcon(":/Images/LEDOff.jpg"), "Test2"));
    10. lv2->setFixedSize(200, 200);
    11. lv2->setWrapping(false);
    To copy to clipboard, switch view to plain text mode 

    i have attached the output "Sample1.png"
    Attached Images Attached Images

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QListView

    I want it to show it on next to each other like <Icon><Text>
    If that is what you want, then you need to set the ViewMode to ListMode, not IconMode.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Use of QListView
    By BrainStorm in forum Qt Programming
    Replies: 5
    Last Post: 3rd August 2010, 05:39
  2. QListView
    By Yayati.Ekbote in forum Qt Programming
    Replies: 2
    Last Post: 1st March 2010, 12:41
  3. QListView
    By Yayati.Ekbote in forum Qt Programming
    Replies: 1
    Last Post: 23rd January 2010, 19:50
  4. QListView
    By moowy in forum Qt Programming
    Replies: 2
    Last Post: 2nd October 2006, 15:14
  5. [QT3] QListView
    By incapacitant in forum Qt Programming
    Replies: 5
    Last Post: 29th January 2006, 15:31

Tags for this Thread

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.