Results 1 to 3 of 3

Thread: Layout modification in QListWidget

  1. #1
    Join Date
    Feb 2010
    Posts
    61
    Thanks
    18
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Layout modification in QListWidget

    Hi,

    I'm using a QListWidget to display some icons vertically. Here is my code:

    Qt Code:
    1. contentsWidget = new QListWidget;
    2. contentsWidget->setViewMode(QListView::IconMode);
    3. contentsWidget->setMovement(QListView::Static);
    4. contentsWidget->setFlow(QListView::TopToBottom);
    5. contentsWidget->setIconSize(QSize(96, 65));
    6. contentsWidget->setMaximumWidth(150);
    7. contentsWidget->setSpacing(12);
    To copy to clipboard, switch view to plain text mode 

    My problem is that the icons appears on the left side of the QListWidget and I would like them to be aligned to the center.

    At the beginning I naturally thought about changing the alignment in the QListWidget layout:

    Qt Code:
    1. contentsWidget->layout()->setAlignment(Qt::AlignHCenter);
    To copy to clipboard, switch view to plain text mode 

    And the code compiled. But the application crashed when I ran it...

    I have looked probably everywhere in Qt's documentation but I still haven't found what I'm looking for. Does somebody know how to set the alignment properly ?

  2. #2
    Join Date
    Feb 2010
    Posts
    61
    Thanks
    18
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: Layout modification in QListWidget

    Hi guys,

    I'm still struggling with this issue. Does anyone have an idea about how to deal with this problem ?

  3. #3
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Layout modification in QListWidget

    My problem is that the icons appears on the left side of the QListWidget and I would like them to be aligned to the center.
    You might be able to do that only with the delegates. Changing layout wont help.

    Have a look at QStyledItemDelegate and QItemDelegate.
    What you will need to do is, set the position of icon drawing(called decoration ) in the options and then call the delegates function to draw the icon.

Similar Threads

  1. QStandardItem color modification
    By prashant in forum Qt Programming
    Replies: 0
    Last Post: 5th November 2009, 09:24
  2. Cancel QTreeWidgetItem item modification
    By ricardo in forum Qt Programming
    Replies: 1
    Last Post: 1st July 2009, 12:21
  3. file modification date/time
    By tommy in forum Qt Programming
    Replies: 1
    Last Post: 18th March 2009, 20:43
  4. QColorDialog style sheet modification
    By Angelo Moriconi in forum Qt Programming
    Replies: 0
    Last Post: 2nd April 2008, 14:20
  5. modification time on files
    By soul_rebel in forum Qt Programming
    Replies: 3
    Last Post: 9th August 2007, 20:51

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.