January 15, 2012

BlackJack BlackJack
Lab Rat
22 posts

[solved] QTableWidgetItem set StyleSheet

 

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

5 replies

January 15, 2012

leon.anavi leon.anavi
Area 51 Engineer
1217 posts

You can customize the style of single cell using method setData [developer.qt.nokia.com]. Try with something like:

  1. table.item(3, 2).setData(Qt.BackgroundRole, QVariant(QColor(Qt::yellow)) );

 Signature 

http://anavi.org/

January 16, 2012

BlackJack BlackJack
Lab Rat
22 posts

thanks, but this unit only color, and how to impose a completely separate style to a cell …

something like

  1. 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 …

January 16, 2012

Gerolf Gerolf
Robot Herder
3286 posts

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.

 Signature 

Nokia Certified Qt Specialist.
Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

January 16, 2012

Gerolf Gerolf
Robot Herder
3286 posts

BlackJack wrote:
thanks, but this unit only color, and how to impose a completely separate style to a cell …

something like

  1. 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 …

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.

 Signature 

Nokia Certified Qt Specialist.
Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

January 16, 2012

BlackJack BlackJack
Lab Rat
22 posts

thanks, that pushed in the right side. topic is closed

 
  ‹‹ Wake up device (N9) when external alarm is triggered      QPainter scaling for non-cosmetic pen width fails for graphicssystem raster ››

You must log in to post a reply. Not a member yet? Register here!