[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



  • 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)) );
    @



  • 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 ...



  • 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.



  • [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.



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.