First I would like to say hello to everyone here, since it's my first mail.

I have certain problem with QString, which tend to crash my program,
when casted to a string. I have following code:

class Element(QObject):
        
        def __init__(self, name, content = None, value = None):
                QObject.__init__(self)
                self.__name = name
                self.__content = content
                self.__value = value
                
        def getValue(self):
                return self.__value
        
        def setValue(self, value):
                self.__value = value
                
        def getName(self):
                return self.__name
                
        def hasContent(self):
                return self.__content != None
                
        def getContent(self):
                return self.__content
                
        def setContent(self, content):
                self.__content = content
                
class Attribute(Element):
        
        def __init__(self, name, content):
                Element.__init__(self, name, content)
        
        def isFinal(self):
                return True
                
        def getValues(self):
                return self.getContent().getValues()
                
        def __repr__(self):
                return str(self.getName()) + " " + str(self.getValue()) + "\n"

And in some other place:

self.connect(box, SIGNAL('currentIndexChanged(QString)'), attribute.setValue);

This works perfect, untial I call print on Attribute object, then the
program crashes.

However, If I change code to:

def setValue(self, value):
        self.__value = str(value)

which is basically moving cast to some earlier point, everything works
fine. Anyone has any idea, why this is wrong? Though it's already
working, I would like to know, why it didn't with previous version.

-- 
Filip Gruszczyński

_______________________________________________
PyQt mailing list    [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to