Results 1 to 5 of 5

Thread: problem in presentation of text-icon QListWidgetItem

  1. #1
    Join Date
    Apr 2010
    Posts
    6
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default problem in presentation of text-icon QListWidgetItem

    Hello EveryBody,

    I am new to the Qt community and says hello to all of you.



    I am trying to build an horizontal QListWidget. This has be done without problem

    the problem is with the QListWidetItem objects I want to insert.
    These QListWidgetItem contain text and icon and they are presented with the icon left an the text wright.
    I'd like to have QListWidgetItem with Icon above and text under the icon


    the source code is:
    Qt Code:
    1. SMListView::SMListView(QWidget *parent) : QWidget(parent)
    2. {
    3. m_listView = new QListWidget(this);
    4. m_listView->setFlow(QListView::LeftToRight);
    5.  
    6. QListWidgetItem *item1 = new QListWidgetItem(QIcon("_2.BMP"), "elem1", m_listView, QListWidgetItem::UserType);
    7. QListWidgetItem *item2 = new QListWidgetItem(QIcon("_2.BMP"), "elem2", m_listView, QListWidgetItem::UserType);
    8. QListWidgetItem *item3 = new QListWidgetItem(QIcon("_2.BMP"), "elem3", m_listView, QListWidgetItem::UserType);
    9. QListWidgetItem *item4 = new QListWidgetItem(QIcon("_2.BMP"), "elem4", m_listView, QListWidgetItem::UserType);
    10. QListWidgetItem *item5 = new QListWidgetItem(QIcon("_2.BMP"), "elem5", m_listView, QListWidgetItem::UserType);
    11.  
    12. item1->setTextAlignment(Qt::AlignCenter);
    13. item2->setTextAlignment(Qt::AlignCenter);
    14. item3->setTextAlignment(Qt::AlignCenter);
    15. item4->setTextAlignment(Qt::AlignCenter);
    16. item5->setTextAlignment(Qt::AlignCenter);
    17. }
    To copy to clipboard, switch view to plain text mode 
    for example the item1 presentation is icon left and text wright
    I'd like to have icon above and the text under the icon


    How to do?

    I'd thank all developpers that have a solution for me.

    Best Regards

  2. #2
    Join Date
    Apr 2010
    Location
    Russia
    Posts
    6
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: problem in presentation of text-icon QListWidgetItem

    Where pictures for icons lie?

  3. The following user says thank you to Chexov for this useful post:

    utopia500 (16th April 2010)

  4. #3
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: problem in presentation of text-icon QListWidgetItem

    See QListView::IconMode with QListView::setViewMode(). Or make your own delegate and draw it like you want.

  5. The following user says thank you to Lykurg for this useful post:

    utopia500 (16th April 2010)

  6. #4
    Join Date
    Apr 2010
    Posts
    6
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: problem in presentation of text-icon QListWidgetItem

    hello Chexov,

    the picture lies in the directory of the executable.
    It works fine now

    Thank you for your help

  7. #5
    Join Date
    Apr 2010
    Posts
    6
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: problem in presentation of text-icon QListWidgetItem

    Quote Originally Posted by Lykurg View Post
    See QListView::IconMode with QListView::setViewMode(). Or make your own delegate and draw it like you want.
    Hello Lykurg,

    Thank you very much for your help. You gave me the solution to my problem
    Best Regards

    utopia500

Similar Threads

  1. Replies: 2
    Last Post: 14th June 2010, 09:40
  2. Rich Text Inside QListWidgetItem?
    By Jick in forum Newbie
    Replies: 1
    Last Post: 17th February 2010, 01:30
  3. Replies: 2
    Last Post: 15th July 2009, 15:53
  4. QListWidgetItem Text Rect
    By js67257 in forum Qt Programming
    Replies: 2
    Last Post: 22nd August 2006, 12:02
  5. QListWidgetItem->text() causing application segfault
    By Valheru in forum Qt Programming
    Replies: 6
    Last Post: 21st August 2006, 22:08

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.