[PyQt] Old problem with overriding QtGui.Qstyle.polish метод.

Igor Prischepoff igor at tyumbit.ru
Wed Apr 23 11:50:52 BST 2008


Hello, experts.
Can anyone please explain why my little app is crashing?
I'm doing anything wrong here?
Please see code below (also as attached file): generally I'm trying to
create 
my own style based on standard styles which comes with qt.
==================================
import sys
from PyQt4 import QtCore, QtGui
# testing abstract style which comes with pyqt 
# it crashes too. :(
class AbstractStyle(QtGui.QStyle):
    def __init__(self,usecols=False):
        super(QtGui.QStyle,self).__init__()
        print "__init__ ok"
    def polish(self,args):
        print "polish started..."
        print "commenting out 'polish' method will prevent crush"
        print "now we going to crash :("

 
class WidgetGallery(QtGui.QWidget):
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
if __name__ == "__main__":
    app = QtGui.QApplication(sys.argv)
    QtGui.QApplication.setStyle(AbstractStyle())
    gallery = WidgetGallery()
    gallery.show()
    sys.exit(app.exec_()) 


===========================
Info: winxp, pyqt 4.3.3 python 2.5
Can anyone check this script with current pyqt snapshot? 
May be this problem is fixed and I should rebuild my pyqt up-to-date ?
Thanks.
---
Igor
igor at tyumbit.ru
-------------- next part --------------
import sys
from PyQt4 import QtCore, QtGui
# testing abstract style which comes with pyqt 
# it crashes too. :(
class AbstractStyle(QtGui.QStyle):
    def __init__(self,usecols=False):
        super(QtGui.QStyle,self).__init__()
        print "__init__ ok"
    def polish(self,args):
        print "polish started..."
        print "commenting out 'polish' method will prevent crush"
        print "now we going to crash :("

 
class WidgetGallery(QtGui.QWidget):
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
if __name__ == "__main__":
    app = QtGui.QApplication(sys.argv)
    QtGui.QApplication.setStyle(AbstractStyle())
    gallery = WidgetGallery()
    gallery.show()
    sys.exit(app.exec_()) 


More information about the PyQt mailing list