Results 1 to 4 of 4

Thread: style a list item

  1. #1
    Join Date
    Feb 2010
    Posts
    2
    Qt products
    Platforms
    Unix/X11

    Default style a list item

    Hi,

    I am new to qt.
    I am working on a GUI in pyqt 4, but someone can answer in qt also.
    In my gui I want to have a List. In one listitem I want to have 4-5 labels and each one aligned to one corner. I want one label to have different font and background and so on...Maybe a checkbox could be in this listitem too, but its not necessary.

    My question is what should I use and how to achieve something like I described or is it possible? Stylesheet, ListWidget, ListView, create my own Model? I think it is easy question for someone skilled in qt, but I dont realy have a clue.
    I tried documentation and google, but no solution...

    I will appreciate any answer.

  2. #2
    Join Date
    Nov 2009
    Posts
    129
    Thanks
    4
    Thanked 29 Times in 29 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: style a list item

    See if the various options for a QStandardItem (setBackground, setCheckable, setFont, setForeground, etc.) are sufficient. If so, then either use a QStandardItemModel to hold the list and a QListView to display it, or do both with QListWidget (and the QListWidgetItems it contains) if that seems easier and gives you all the control you need.

  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: style a list item

    If your items are not too many, QListWidget is the easiest to use. Combine them with use of delegates( QItemDelegate and QStyledItemDelegate) and you get power to control the drawing.
    Also if you just want to have alternate colors for row, there's a function QListWidget::setAlternatingRowColors

  4. #4
    Join Date
    Feb 2010
    Posts
    2
    Qt products
    Platforms
    Unix/X11

    Default Re: style a list item

    Thank you fot replies. I am using now the QStyledItemDelegate with QListWidget, I found it the easiest and sufficient.

Similar Threads

  1. list view displaying same item value...
    By addu in forum Newbie
    Replies: 1
    Last Post: 30th May 2009, 01:55
  2. list view item problem..
    By addu in forum Qt Programming
    Replies: 5
    Last Post: 29th May 2009, 11:26
  3. list of custom item views?
    By Beluvius in forum Qt Programming
    Replies: 1
    Last Post: 29th March 2008, 06:43
  4. Skype style list.
    By bunjee in forum Qt Programming
    Replies: 4
    Last Post: 29th January 2007, 15:49
  5. deleting first item in a list
    By soul_rebel in forum Qt Programming
    Replies: 2
    Last Post: 6th April 2006, 17:49

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.