I was trying to extend a Qt class in C++ and using this in my Python
application. I got problems importing the python module:
I was extending QListViewItem to QListViewItemNu meric. Then I used the
following to generate the python extension:
$ gcc -c -I/usr/include/qt3 -I/usr/include/python2.3
QListViewItemNu meric.cpp
Then I used swig with an interface file:
-- snip --
%module QListViewItemNu meric
%{
#include <qlistview.h>
#include "QListViewItemN umeric.h"
%}
class QListViewItemNu meric : public QListViewItem {
public:
QListViewItemNu meric( QListView * parent );
virtual void setNumeric( int columns = 0 );
};
-- pins --
And compiled the result:
$ swig -c++ -python QListViewItemNu meric.i \
QListViewItemNu meric.i:6: Warning(401): Nothing known about class
'QListViewItem' . Ignored.
$ gcc -c -I/usr/include/qt3 -I/usr/include/python2.3 \
QListViewItemNu meric_wrap.cxx
And linked both together with qt:
$ gcc -shared QListViewItemNu meric.o QListViewItemNu meric_wrap.o -lqt -o \
_QListViewItemN umeric.so
When I omitted the "-lqt" python import told me:
ImportError: ./_QListViewItemN umeric.so: undefined symbol:
_ZN13QListViewI temC2EP9QListVi ew
which I figured out from the manual means I have to link it against the Qt
library. I am not sure wether "-lqt" is the right thing to do.
However, using the "-lqt" switch I now get a:
import QListViewItemNu meric
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "QListViewItemN umeric.py", line 5, in ?
import _QListViewItemN umeric
ImportError: ./_QListViewItemN umeric.so: undefined symbol:
_ZTV20QListView ItemNumeric
Can anyone help me over these first steps of using swig?
Thanks
Uwe