[PyQt] about the sip wrappers

Phil Thompson phil at riverbankcomputing.com
Mon Aug 23 10:06:57 BST 2010


On Mon, 23 Aug 2010 11:30:55 +0800, "燕子" <xiaoyan0325 at tom.com> wrote:
> Dear sir.
>  my head file is </:includetail>
>  myqtlibtest.h:</:includetail>
>  #ifndef MYQTLIBTEST_H
> #define MYQTLIBTEST_H</:includetail>
>  #include "myqtlibtest_global.h"
> //#include <windows.h>
> #include <qstring.h>
> #include <qdebug.h>
> #include "test.h"</:includetail>
>  class MYQTLIBTEST_EXPORT myqtlibtest
> {
> public:
>  myqtlibtest();
>  ~myqtlibtest(); </:includetail>
>   void show();
>  int testshow();</:includetail>
>  private:
>  Test *testpointer;</:includetail>
>  };
> MYQTLIBTEST_EXPORT int myshow(int aa);</:includetail>
>  #endif // MYQTLIBTEST_H</:includetail>
>  my sip wrappers is</:includetail>
>  myqtlibtest.sip:</:includetail>
>  %Module myqtlibtest 0</:includetail>
>  
> %Import QtCore/QtCoremod.sip
> %Import QtGui/QtGuimod.sip
>  class  myqtlibtest
> {
>  %TypeHeaderCode
>  #include "myqtlibtest.h"
>  %End
>  public:
>  myqtlibtest();
>  ~myqtlibtest();
>        void show();
>        int testshow();
>   private:
>  Test *testpointer;
> };
> int myshow(int aa);
>   
>  when I run the command of "sip -I ..\sip\PyQt4\ -t Qt_4_5_3  -t WS_WIN
>  myqtlibtest.sip
> "
>   
>   the error is "sip:myqtlibtest.sip :23:Class variables must be in the
>   public section." but I still need the private variable "Test
>   *testpointer"
>   
>  what can I do?

If you need the variable in your C++ code then just omit it from the .sip
file. If you need it from you Python code then you can't and need to change
the C++ to make it public.

Phil


More information about the PyQt mailing list