[PyQt] SIP wrapper: argument 1 has unexpected type 'QWidget'

Glenn Ramsey gr at componic.co.nz
Wed Oct 5 08:45:39 BST 2011


On 05/10/11 20:18, Phil Thompson wrote:
> On Wed, 05 Oct 2011 10:23:18 +1300, Glenn Ramsey<gr at componic.co.nz>
> wrote:
>> I'm having some trouble with a simple SIP wrapper for a QWidget derived
>> class.
>> I get the error "HostWidget(): argument 1 has unexpected type 'QWidget'"
>> but
>> that constructor is supposed to accept a QWidget.
>>
>> What am I doing wrong?
>>
>> Glenn
>>
>> # SIP definition
>> class HostWidget : QLabel {
>>
>> %TypeHeaderCode
>> #include "hostwidget.h"
>> %End
>>
>> public:
>>       HostWidget(QWidget *parent /TransferThis/ =0, Qt::WindowFlags f=0);
>>
>> signals:
>>       void resize(QResizeEvent* evt);
>>       void change(QEvent* evt);
>> };
>>
>> # Test program
>> import sys
>> from PyQt4.QtGui import QApplication, QWidget
>>
>> from MyModule import HostWidget
>>
>> try:
>>       a = QApplication(sys.argv)
>>       w = QWidget()
>>       h = HostWidget(w)
>> except Exception as e:
>>       print(str(e))
>>
>> # Output
>> HostWidget(): argument 1 has unexpected type 'QWidget'
>
> Nothing obviously wrong, so you need to provide a complete example and
> version numbers.
>
> Phil

Ok, Thanks. A bit more searching seems to indicate that this problem might be 
caused by a version mismatch. I recently updated Visual Studio which may be 
relevant. I'm going to rebuild PyQt and see if that helps.

Glenn



More information about the PyQt mailing list