I changed the 'QtCore.Qt.red' to 'QBrush(Qt.red)' and works!
Here is a small working example:
when I comment out the line 'from PyQt4.QtCore import *', I get an error 'Qt unresolved reference' even though I have the line 'from PyQt4 import QtGui, QtCore'.
So, what is the proper way to import QtCore without having to import it twice?
Here is a small working example:
from PyQt4 import QtGui, QtCore from PyQt4.QtCore import * from PyQt4.QtGui import * import sys def main(): app = QApplication(sys.argv) w = MyWindow() w.show() sys.exit(app.exec_()) class MyWindow(QTableView): def __init__(self, *args): QTableView.__init__(self, *args) model = QtGui.QStandardItemModel(0, 2) self.setModel(model) for i in range(0,6): newRow = model.rowCount(); model.insertRow(newRow); # paint first two rows for i in range(0, 2): model.setData(model.index(i, 0), QBrush(Qt.red), QtCore.Qt.BackgroundRole) model.setData(model.index(i, 1), QBrush(Qt.red), QtCore.Qt.BackgroundRole) if __name__ == "__main__": main()But I do have a question:
when I comment out the line 'from PyQt4.QtCore import *', I get an error 'Qt unresolved reference' even though I have the line 'from PyQt4 import QtGui, QtCore'.
So, what is the proper way to import QtCore without having to import it twice?