PDA

View Full Version : style a list item



savar
11th February 2010, 21:58
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.

Coises
12th February 2010, 04:39
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.

aamer4yu
12th February 2010, 05:31
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 :)

savar
18th March 2010, 19:21
Thank you fot replies. I am using now the QStyledItemDelegate with QListWidget, I found it the easiest and sufficient.