[solved] QTableWidgetItem set StyleSheet
-
wrote on 15 Jan 2012, 13:14 last edited by
Good day
I have a QTableWidget, if there is some opportunity to set the StyleSheet for a specific item in the table, for example, item(3,2) ???
In advance I thank
-
wrote on 15 Jan 2012, 21:07 last edited by
You can customize the style of single cell using method "setData":http://developer.qt.nokia.com/doc/qt-4.8/qtablewidgetitem.html#setData. Try with something like:
@
table.item(3, 2).setData(Qt.BackgroundRole, QVariant(QColor(Qt::yellow)) );
@ -
wrote on 16 Jan 2012, 09:04 last edited by
thanks, but this unit only color, and how to impose a completely separate style to a cell ...
something like
@item(3,2).setStyleSheet("border:1px solid grey; border-bottom-left-radius: 5px;border-bottom-right-radius: 5px;")@need to do a completely different style from the cell ...
-
wrote on 16 Jan 2012, 09:07 last edited by
Stylesheets always work on widgets.
Inside views, it is not possible to address single items with a style sheet or set a style sheet on them.
-
wrote on 16 Jan 2012, 09:09 last edited by
[quote author="BlackJack" date="1326704668"]thanks, but this unit only color, and how to impose a completely separate style to a cell ...
something like
@item(3,2).setStyleSheet("border:1px solid grey; border-bottom-left-radius: 5px;border-bottom-right-radius: 5px;")@need to do a completely different style from the cell ...[/quote]
This is not possible by styling.
It can only be achieved by creating a delegate which does customized painting. But take care, if you change borders and margins, the size of the cell might change so you have to adopt the rest of the row / rolumn. -
wrote on 16 Jan 2012, 13:03 last edited by
thanks, that pushed in the right side. topic is closed
6/6