[PyQt] Possible QTreeWidgetItem constructor bug

Glenn Ramsey gr at componic.co.nz
Wed Apr 18 04:33:19 BST 2012


On 16/04/12 23:47, Phil Thompson wrote:
> On Mon, 16 Apr 2012 14:46:54 +1200, Glenn Ramsey<gr at componic.co.nz>
> wrote:
>> If this QTreeWidgetItem constructor is called with a single string
> instead
>> of a
>> list of strings for the "strings" parameter, then on my system (Win 7,
>> Python
>> 2.6.5, Qt 4.7.4, PyQt 4.8.5) it crashes the python interpreter.
>>
>> QTreeWidgetItem.__init__ (self, QTreeWidget parent, QStringList strings,
>> int
>> type = QTreeWidgetItem.Type
>>
>> Shouldn't that cause an Attribute error to be raised?
>
> No. PyQt allows any sequence of strings to be used where a QStringList is
> expected - and a string is a sequence of (1 character) strings.
>
> However it shouldn't crash (unless it is a Qt bug). Have you got a
> complete test script that demonstrates the problem?
>
> Phil

A simple test didn't cause the error, and I now I can't reproduce it in my app 
code by reinstating the previously offending line, so it looks like something 
else must have been also contributing to the crash. The only clue I have is that 
I changed the string to a list and the crash went away.

Glenn



More information about the PyQt mailing list