[SOLVED]How to set the background color of a cell in QTableWidget while editing?
-
wrote on 10 May 2014, 02:36 last edited by
I have a editable, spreadsheet-like table created using QTableWidget with QTableWidgetItems. It is functionally doing exactly what I wish it to do. I have set the QTableWidgetItems to be editable. However, I am having problem with setting the background color of the cells while editing.
I have set the color of the background color of the cells and the current selected cells using stylesheets.
@
QTableWidget::item {
background-color: green;
}QTableWidget::item:selected {
background-color: red;
}
@Once I double click on the cell to edit the contents of the QTableWidgetItem, the color of the background will change to white. I wish the color to remain while the user is editing the cell. Focus, and edit-focus did not help to set the background color of the editing cell.
@
QtableWidget::item:focus {
background-color: yellow;
}QtableWidget::item:edit-focus {
background-color: yellow;
}
@I am on a Windows 7/xp machine, using qt-mingw 5.2.1 build.
-
wrote on 10 May 2014, 07:45 last edited by
Hey,
the default delegate uses a QLineEdit, so just define a style for it:
QLineEdit {
background: yellow;
}bb
-
wrote on 10 May 2014, 12:33 last edited by
It works, thank you!
1/3