[PyKDE] [PyQt] [3] Segfault when accessing a QString after emission

Marco Wahl mw.visenso at googlemail.com
Tue Sep 12 10:59:35 BST 2006


Hi!

This is driving me mad:

[[[
Python 2.4.1 (#7, Aug  3 2005, 14:55:58)
[GCC 3.3.1 (SuSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from qt import *
>>> import sys
>>> app = QApplication(sys.argv)
>>> class ConnBox(QObject):
...     def __init__(self, *args):
...         apply(QObject.__init__,(self,)+args)
...         self.arg = None
...     def slotSetOneArgToStr(self, arg):
...         self.arg = str(arg)
...     def slotSetOneArg(self, arg):
...         self.arg = arg
...
>>> le = QLineEdit(None)
>>> cb = ConnBox()
>>> QObject.connect(
...     le, SIGNAL('textChanged(const QString&)'),
...     cb.slotSetOneArgToStr)
True
>>> le.setText('foo')
>>> print cb.arg
foo
>>> QObject.disconnect(
...     le, SIGNAL('textChanged(const QString&)'),
...     cb.slotSetOneArgToStr)
True
>>> QObject.connect(
...     le, SIGNAL('textChanged(const QString&)'),
...     cb.slotSetOneArg)
True
>>> le.setText('bar')
>>> cb.arg
<qt.QString object at 0x402adfac>
>>> print cb.arg

Process Python segmentation fault
]]]

What is the problem here?  Why can't I store a QString like a
Python-string?  Can anyone explain?


TIA and best wishes,  Marco




More information about the PyQt mailing list