I can confirm this problem on my system. Can you send along the .ui file used to create table? I can submit a bug on your behalf once I have that file.
The problem seems to be a bug in pyside-uic. It creates a brush for the BG, then replaces it with the FG brush, and then applies that brush to both the BG and FG. The background is white in the 2-4 cells because the FG brush style is set to QtCore.Qt.NoBrush, probably because text only uses the color, not the brush type (i.e. text cannot have a diagonal pattern, or a gradient). Since this FG brush gets applied to the background, the background defaults to white. When the text color is not specified (i.e. it defaults to black), then a FG brush is not created and the background shows. I expect that if you were to manually specify the text color as black, then the background color would always be white. Ben On Sun, Oct 16, 2011 at 9:10 PM, Ricardo Manriquez < ricardo.manriq...@gmail.com> wrote: > The problem goes like this I'm trying to get a table which looks like > a semaphore so for the dark colors I chose white text in Qt 4.7 using > C++ It works correctly just as It shows in Designer but when I execute > it with pyside the text color disables the background color. If chose > black as background and white as foreground the result is a white cell > with white text. The problem shows up in windows and linux. > > Please help me file a bug if it's necessary > > I'm attaching my code here, generated by pyside-uic > > # -*- coding: utf-8 -*- > > # Form implementation generated from reading ui file 'test.ui' > # > # Created: Sun Oct 16 21:58:39 2011 > # by: pyside-uic 0.2.13 running on PySide 1.0.7 > # > # WARNING! All changes made in this file will be lost! > > from PySide import QtCore, QtGui > > class Ui_MainWindow(object): > def setupUi(self, MainWindow): > MainWindow.setObjectName("MainWindow") > MainWindow.resize(236, 97) > MainWindow.setWindowTitle("MainWindow") > self.widget = QtGui.QWidget(MainWindow) > self.widget.setObjectName("widget") > self.horizontalLayout = QtGui.QHBoxLayout(self.widget) > self.horizontalLayout.setObjectName("horizontalLayout") > self.tableWidget = QtGui.QTableWidget(self.widget) > self.tableWidget.setObjectName("tableWidget") > self.tableWidget.setColumnCount(2) > self.tableWidget.setRowCount(2) > item = QtGui.QTableWidgetItem() > self.tableWidget.setVerticalHeaderItem(0, item) > self.tableWidget.verticalHeaderItem(0).setText("1") > item = QtGui.QTableWidgetItem() > self.tableWidget.setVerticalHeaderItem(1, item) > self.tableWidget.verticalHeaderItem(1).setText("2") > item = QtGui.QTableWidgetItem() > self.tableWidget.setHorizontalHeaderItem(0, item) > self.tableWidget.horizontalHeaderItem(0).setText("1") > item = QtGui.QTableWidgetItem() > self.tableWidget.setHorizontalHeaderItem(1, item) > self.tableWidget.horizontalHeaderItem(1).setText("2") > brush = QtGui.QBrush(QtGui.QColor(255, 0, 0)) > brush.setStyle(QtCore.Qt.SolidPattern) > item = QtGui.QTableWidgetItem() > item.setBackground(brush) > self.tableWidget.setItem(0, 0, item) > self.tableWidget.item(0, 0).setText("Black FG Red BG") > brush = QtGui.QBrush(QtGui.QColor(255, 0, 0)) > brush.setStyle(QtCore.Qt.SolidPattern) > brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) > brush.setStyle(QtCore.Qt.NoBrush) > item = QtGui.QTableWidgetItem() > item.setBackground(brush) > item.setForeground(brush) > self.tableWidget.setItem(0, 1, item) > self.tableWidget.item(0, 1).setText("White FG Red BG") > brush = QtGui.QBrush(QtGui.QColor(255, 0, 0)) > brush.setStyle(QtCore.Qt.SolidPattern) > brush = QtGui.QBrush(QtGui.QColor(255, 255, 0)) > brush.setStyle(QtCore.Qt.NoBrush) > item = QtGui.QTableWidgetItem() > item.setBackground(brush) > item.setForeground(brush) > self.tableWidget.setItem(1, 0, item) > self.tableWidget.item(1, 0).setText("Yellow FG Red BG") > brush = QtGui.QBrush(QtGui.QColor(255, 0, 0)) > brush.setStyle(QtCore.Qt.SolidPattern) > brush = QtGui.QBrush(QtGui.QColor(255, 255, 0)) > brush.setStyle(QtCore.Qt.NoBrush) > item = QtGui.QTableWidgetItem() > item.setBackground(brush) > item.setForeground(brush) > self.tableWidget.setItem(1, 1, item) > self.tableWidget.item(1, 1).setText("Yellow FG Red BG") > self.horizontalLayout.addWidget(self.tableWidget) > MainWindow.setCentralWidget(self.widget) > > self.retranslateUi(MainWindow) > QtCore.QMetaObject.connectSlotsByName(MainWindow) > > def retranslateUi(self, MainWindow): > __sortingEnabled = self.tableWidget.isSortingEnabled() > self.tableWidget.setSortingEnabled(False) > self.tableWidget.setSortingEnabled(__sortingEnabled) > > > if __name__ == "__main__": > import sys > app = QtGui.QApplication(sys.argv) > MainWindow = QtGui.QMainWindow() > ui = Ui_MainWindow() > ui.setupUi(MainWindow) > MainWindow.show() > sys.exit(app.exec_()) > > _______________________________________________ > PySide mailing list > PySide@lists.pyside.org > http://lists.pyside.org/listinfo/pyside > >
_______________________________________________ PySide mailing list PySide@lists.pyside.org http://lists.pyside.org/listinfo/pyside