Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QTableWidget - How to set background-color with widget
I try to set a background color to my QTableWidget (particular celle or row) with setBackgroundColor.
This function works with QTableWidgetItem but crashes with others items like QCheckBox are contained in the grid
Is there any other function to set the color in a cell/row ?
I've already tried *setstylesheet *function, which crashes too...
Can you share the code you use to setup the background color and widgets ?
yes of course :
tableItem = new QTableWidgetItem("");
tableItem->setFlags(tableItem->flags() & ~(Qt::ItemIsEditable));
//Add Table items here With Default Cell Texts
The background-color works only for "QTableWidgetItem" cells (without widget)
When you set a cell widget you don't see the item underneath (and you don't have any under), you have to set the background on the widget itself.
fgdevel last edited by fgdevel
is there any global function to set the background-color ? (which works with or without widget...) ?
You can try by modifying the palette of the application.
I want to modify a specific TableWidget and not all grids or all widget contained in the application...Have you an example ?
You want to modify only that widget and all its children ?
I want to modify all cells of QTableWidget, several cells contain QTableWidgetItem, several cells contain QCheckbox for example
Then you can write the style sheet so that it applies to both your QTableWidget and its children widgets
It seems to work on QTableWidget but not on children widgets when I set the style sheet
I have resolved my problem with :