[PyQt] QList / SIP / Python weirdism...
Jamie Riotto
jamie.riotto at gmail.com
Wed Dec 16 19:42:15 GMT 2009
Ok, got my library working with QT classes (thanks Phil!), but I'm seeing
strange behavior with QList (I can set the list, but not append to
it). For example I have
Object.h:
Class Object() {
Public:
Object();
QString name;
QList<int> testlist;
};
and Object.sip:
%Import QtCore/QtCoremod.sip
%Module ObjectLib 0
class Object {
%TypeHeaderCode
#include "Object.h"
%End
public:
Object();
QString name;
QList<int> testlist;
};
Everything compiles / links ok (Windows, QT 4.5, SIP 4.6.1) but when I
run a Python shell I get:
from ObjectLib import *
foo = Object()
print foo.testlist
foo.testlist.append(7)
print foo.testlist
foo.testlist = [3,4,5]
print foo.testlist
foo.testlist[0] = 9
print foo.testlist
foo.testlist.pop(0)
print foo.testlist
=========================================
Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit
(Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>>
[ ]
[ ]
[3, 4, 5]
[3, 4, 5]
[3, 4, 5]
>>>
==============================================
I.e.the Append, the [ ] index operation and the Pop did not work. Am I
doing something wrong?
Thanks for the help - jamie
More information about the PyQt
mailing list