[PyQt] QGradient segmentation fault ?
Laurent Hamery
laurent-h at moving-picture.com
Fri Jan 11 15:00:50 GMT 2008
hi guys,
I have a problem with the QLinearGradient(or even QGradient..).
Im trying to set another stops list to the gradient, but it produce a
segmentation fault.
Is it a bug or did I do something wrong ?
Note that Im using PyQt 4.2 with python 2.4.3 but I cant upgrade to
newer versions as we are currently in production...
Cheers
Laurent
import sys
from PyQt4.QtGui import *
from PyQt4.QtCore import *
class PyTest(QWidget):
def __init__(self, parent=None):
QWidget.__init__(self, parent)
self.gradient = QLinearGradient(0, self.height()/2,
self.width(), self.height()/2);
self.newStops = []
self.entry1 = tuple([0.0, QColor(Qt.blue)])
self.entry2 = tuple([1.0, QColor(Qt.green)])
self.newStops.append(self.entry1)
self.newStops.append(self.entry2)
print 'setStops: ' + str(type(self.newStops))
print 'stop: ' + str(type(self.newStops[0]))
print 'list: ' + str(self.newStops)
self.gradient.setStops(self.newStops)
def paintEvent(self, event):
self.gradient.setFinalStop(QPointF(self.width(), self.height()/2))
painter = QPainter(self)
painter.setBrush(QBrush(self.gradient))
painter.fillRect(0, 0, self.width(), self.height())
if __name__ == '__main__':
app = QApplication(sys.argv)
widget = PyTest()
widget.show()
sys.exit(app.exec_())
More information about the PyQt
mailing list