[PyQt] Change background color of section in QHeaderView
Hello, I have a QTableView with headers. The headers need a different background-color , depending if the items are set to editable. This can be toggled for the entire column by clicking the header. If the items are editable, the header must have a green background, otherwise red. I try to implement it using stylesheets (using ::section:checked). The header changed color, but when I go to the next column (pressing right arrow) the background of the header in that column changes as well. And that's not what I want. I used setHeaderData as well, but that doesn't seem to do anything. What I want is: Click the header of a certain column once: background of header turns red Click the header again, background of header turns green. Other headers must remain the same unless they are clicked too. What's the best way to solve this problem? Thanks, Peter ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] issue with QPainter.drawPolyline and list of QPoints
Hi Phil, shouldn't this work: from PyQt4 import QtCore, QtGui app = QtGui.QApplication([]) pixmap = QtGui.QPixmap(16, 16) painter = QtGui.QPainter(pixmap) plist = [QtCore.QPoint(0, 15), QtCore.QPoint(0, 0), QtCore.QPoint(15, 0)] painter.drawPolyline(plist) With PyQt 4.9, this results in: TypeError: arguments did not match any overloaded call: QPainter.drawPolyline(QPointF, ...): argument 1 has unexpected type 'list' QPainter.drawPolyline(QPolygonF): argument 1 has unexpected type 'list' QPainter.drawPolyline(QPoint, ...): argument 1 has unexpected type 'list' QPainter.drawPolyline(QPolygon): argument 1 has unexpected type 'list' QPaintDevice: Cannot destroy paint device that is being painted Speicherzugriffsfehler although you provide a %MethodCode handler for the list of QPoints case. Ref: line 354 in sip/QtGui/qpainter.sip Hmm, Pete ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Parent/Child widget clipping
So after tinkering with this a bit more, I'm in another conundrum, lol... When I replace the 'child-table' (QTableWidget) with another kind of widget, and give a size using 'setGeometry'...the solution no longer works... Why is that? What am I doing wrong, Pete? # #!/usr/bin/env python import sys from PyQt4 import QtGui, QtCore class MainExample(QtGui.QWidget): def __init__(self, pParent=None): super(MainExample, self).__init__(pParent) scrX = 2048 scrY = 1152 winX = 550 winY = 400 pX = (scrX - winX) / 2 pY = (scrY - winY) / 2 self.setGeometry(pX, pY, winX, winY) self.setLayout(QtGui.QVBoxLayout()) self.LargeTable = QtGui.QTreeWidget() self.LargeTable.setColumnCount(3) self.layout().addWidget(self.LargeTable) *self.widget = QtGui.QWidget(self) self.widget.setGeometry(QtCore.QRect(10, 10, 400, 300))* for i in range(0, 2): parent = QtGui.QTreeWidgetItem(self.LargeTable, ['Parent %s' % i] ) for j in range(0, 3): child = QtGui.QTreeWidgetItem(parent, ['Child %s' % j]) * self.LargeTable.setItemWidget(self.LargeTable.topLevelItem(0).child(1), 0, self.widget)* self.LargeTable.setFirstItemColumnSpanned(self.LargeTable.topLevelItem(0).child(1), True) self.LargeTable.expandAll() if __name__ == '__main__': app = QtGui.QApplication(sys.argv) form = MainExample() form.show() form.raise_() sys.exit(app.exec_()) # -- View this message in context: http://python.6.n6.nabble.com/Parent-Child-widget-clipping-tp4352146p4355087.html Sent from the PyQt mailing list archive at Nabble.com. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt