Set background color questions
-
wrote on 15 Feb 2019, 22:08 last edited by
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 ? -
wrote on 15 Feb 2019, 22:20 last edited by
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.
-
wrote on 15 Feb 2019, 22:30 last edited by
-
Are you sure the text is not simply not contrasted enough to be properly seen ?
-
wrote on 15 Feb 2019, 22:55 last edited by
I got it now, I just deleted line 222 and it works.
Thank you!
-
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 :)
1/7