Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Set background color questions
I want to set the background color of QTableWidgets in Qt5 using python, the code is ( self.people_table.setItem(count,j,QtWidgets.QTableWidgetItem()) self.people_table.item(count, j).setBackground(QtGui.QColor(167, 89, 109)), but it overwritten the original values. Can anyone help?
Hi and welcome to devnet,
Please us coding tags to display your code properly.
Your question is not clear.
What gets overwritten ?
What do you expect ?
What do you get ?
Hi, thanks for replying, people_table is a table, count is the row index and j is the column index. What I want to do is to set the background color in the cell at index (count j) and at the same time maintains the original text in the cell, but what I get is only the color. Text has been covered by the background color.
Starting from 217, what's before is writing text onto the table.
Are you sure the text is not simply not contrasted enough to be properly seen ?
I got it now, I just deleted line 222 and it works.
Indeed... You were replacing the item before modify its background.
Since you have it working now, please mark the thread as solved using the "Topic Tools" button so that other forum users may know a solution has been found :)