[PyQt] Unable to get the wrapping Class by sip
Phil Thompson
phil at riverbankcomputing.com
Tue Dec 15 08:43:02 GMT 2009
On Tue, 15 Dec 2009 09:36:42 +0800, "燕子" <xiaoyan0325 at tom.com> wrote:
> I'm on Windows using Microsoft Visual Stdio2008, Python 3.1,
> PyQt-win-gpl-4.6.2, sip-4.9.2 and Qt 4.5.3.
> First,I have myqtlibtest.h; myqtlibtest.lib;myqtlibtest.dll from the
> myqtlibtest project.It's simple.Just like this:
>
> myqtlibtest.h:
>
> #ifndef MYQTLIBTEST_H
> #define MYQTLIBTEST_H
> #include "myqtlibtest_global.h"
> #include <qstring.h>
> #include <qdebug.h>
> class MYQTLIBTEST_EXPORT myqtlibtest
> {
> public:
> myqtlibtest();
> ~myqtlibtest();
> void show(){
> qDebug()<<QString("hello");
> }
> private:
> };
> #endif // MYQTLIBTEST_H
>
>
> when I wrap with SIP. Then my sip file is like this:
>
> myqtlibtest.sip:
>
> %Module myqtlibtest 0
> %Import
C:/Python31/Lib/site-packages/PyQt4/sip/PyQt4/QtCore/QtCoremod.sip
>
> %If (Qt_4_5_3 -)
>
> class myqtlibtest
> {
> %TypeHeaderCode
> #include "myqtlibtest.h"
> %End
> public:
> myqtlibtest();
> ~myqtlibtest();
> void show();
> private:
> };
> %End
>
> I'd like to add Qt classes to my python program.
>
> I've gotten the file of myqtlibtest.pyd by my sip file, but when I run my
> myqtlibtest.pyd ,I got nothing just like this:
> when I run it on python idle.(myqtlibtest is my module)
>
>
>>>> import myqtlibtest
>
>>>> help(myqtlibtest)
>
> Help on module myqtlibtest:
>
>
>
> NAME
>
> myqtlibtest
>
>
>
> FILE
>
> c:\python31\dlls\myqtlibtest.pyd
>
>
>
> >>> myqtlibtest.myqtlibtest()
> Traceback (most recent call last):
> File "<pyshell#11>", line 1, in <module>
> myqtlibtest.myqtlibtest()
> AttributeError: 'module' object has no attribute 'myqtlibtest'
>>>> a=myqtlibtest.myqtlibtest()
> Traceback (most recent call last):
> File "<pyshell#12>", line 1, in <module>
> a=myqtlibtest.myqtlibtest()
> AttributeError: 'module' object has no attribute 'myqtlibtest'
>>>>
>
> Where is the wrapping class?
> Any help? Thanks - susan
What flags did you pass to sip when generating the code for your module?
My guess is that you didn't pass the right -t flag to enable the Qt_4_5_3
test.
Phil
More information about the PyQt
mailing list