Unsolved Set text color for QTableWidget cell widget when cell selected.
-
I have a date edit widget that is assigned as the cell widget for my QTableWidget. As you can see in the attached screenshot, the second column text turns white when the row is selected but my custom widget in the first column obviously stays black.
I want the custom widget to change its text color using the palette in the same way that a normal QTableWidgetItem does when the row is selected.
What is the best way to do this? Just set the color manually when the selected row changes, or a more comprehensive one which integrates the palette of the custom widget and the table a little better?
Thanks!
-
@patrickkidd said in Set text color for QTableWidget cell widget when cell selected.:
What is the best way to do this?
Don't use
setItemWidget
. The default editor factory already handlesQDate
s with aQDateEdit
. Ther's no need to do anything special to have a date editor in your cell containingQDate
-
The QDateEdit is quite clunky and incomplete so I customized it for my needs.
-
Then just subclass
QStyledItemDelegate
and makecreateEditor
return your editor