PDA

View Full Version : how to specify item's style in QTableView?



nifei
23rd February 2009, 10:30
hi, I'm writing style sheet for QTableView and need to specify single item's appearance. how to change single item's style, such as border and background color? if the item has no special state compared with other items. can we set property like QWidgets to items in the view?

Lykurg
23rd February 2009, 10:57
Give that item a unique object name and use it as a selector in CSS.

nifei
23rd February 2009, 11:21
Give that item a unique object name and use it as a selector in CSS.

Sadly QStandardItem is not a subclass of QObject so no object name could be given, and QTableView : : item {...} in style sheet is a type of sub-control other than a widget.

aamer4yu
23rd February 2009, 15:32
I guess delegates would be better to use.
You can always setData of item through some role, and use this role to do your decoration in the delegate :)

Lykurg
23rd February 2009, 16:22
Sadly QStandardItem is not a subclass of QObject so no object name could be given

Ups, you are right, but then - not tested! - create your subclass which also have QObject as a parent, and CSS should work.