[PyQt] Pyqt 5.1.1, problem when passing enum as parameter (assetion fails)

Phil Thompson phil at riverbankcomputing.com
Fri Oct 25 17:31:36 BST 2013


On Mon, 21 Oct 2013 15:14:23 +0200, Julien Pauty <julien.pauty at gmail.com>
wrote:
> Hi,
> 
> Using version 5.1.1 of PyQt and 4.15.3 of sip. Qt 5.1
> 
> When passing an enum as an argument to a method, the following assert
> fails:
> 
> siplib.c:8356: sip_api_can_convert_to_type: Assertion `(((td)->td_flags
&
> 0x0007) == 0x0000) || (((td)->td_flags & 0x0007) == 0x0002)' failed.
> 
> 
> With PyQt 5.0.1 we did not have this problem. Is there something special
to
> do with enums with PyQt 5.1.1 ?

No.

> Here is a small example to reproduce the problem:
> 
> 
> Header:
> class QDockWorkspace
> :    public QWidget
> {    Q_OBJECT
>     public :
>         QDockWorkspace(QWidget* parent,Qt::DockWidgetAreas
allowedAreas);
>         virtual ~QDockWorkspace();
> 
>     private :
>         Qt::DockWidgetAreas m_allowedAreas;
> };
> 
> cc file:
> QDockWorkspace::QDockWorkspace(QWidget* parent,Qt::DockWidgetAreas
> allowedAreas)
> :    QWidget(parent)
> ,    m_allowedAreas(allowedAreas)
> {}
> 
> QDockWorkspace::~QDockWorkspace()
> {}
> 
> Sip:
> class QDockWorkspace : QWidget
> {
> %TypeHeaderCode
> #include "qdockworkspace.hh"
> %End
>     public :
>         QDockWorkspace(QWidget* parent /TransferThis/ );//,
> Qt::DockWidgetAreas allowedAreas );
>         virtual ~QDockWorkspace();
> };
> 
> The python part:
> import PyQt5.Qt as qt
> application = qt.QApplication([])
> import myModule
> myModule.QDockWorkspace2(None,0)

One obvious problem is your .sip doesn't match your .cc file. Maybe you
have code from previous attempts getting mixed up.

Phil


More information about the PyQt mailing list