Could the qtablewidgetitem set the stylesheet?
-
I found that the item object is not inherited from the qobject .I just want to use the stylesheet on the qtablewidgetitem.
Or is there a simple way to modify the style of the items?not the whole style ,may be many colors or and so on. -
I found that the item object is not inherited from the qobject .I just want to use the stylesheet on the qtablewidgetitem.
Or is there a simple way to modify the style of the items?not the whole style ,may be many colors or and so on.@nicker-player
As you have discoveredQTableWidgetItems are notQWidgets and hence cannot have stylesheets applied to them. You can styleQTableWidget/QTableViewand their items (e.g.QTableView::item) as a whole, but not individual items if that is what you want.If you want to access individual items you would need to do that in code by overriding
QTableWidget::data()or callingQTableWidget::setData()with one of the roles it offers, or there are a few specific methods to do this, e.g.QTableWidgetItem::setForeground(). -
A custom item delegate might be required.