[PyQt] SIP gives error when trying to subclass QVariant

Nate Reid gnatty7 at hotmail.com
Tue Apr 16 19:53:37 BST 2013


Versions: Redhat Linux EL6Qt 4.7.1 (also tested with 4.8.2)PyQt: 4.10Python: 2.7.4Sip: 4.14
Sip 4.14, and 4.13 as well gives me the following error when trying to generate code on the following sip file:sip -x VendorID -t WS_X11 -x PyQt_NoPrintRangeBug -t Qt_4_7_1 -g -I /usr/pic1/root/share/sip/PyQt4 -c . python/TestQVariant.sipsip: python/TestQVariant.sip:6: A class, exception, namespace or mapped type has already been defined with the same name
// TestQVariant.sip:%Module TestQVariant
%Import QtCore/QtCoremod.sip
class TestQVariant : public QVariant{%TypeHeaderCodeinclude "TestQVariant.h"$Endpublic:    TestQVariant(void);
    TestQVariant(const QVariant &v);        TestQVariant(int v);        TestQVariant(double v);       TestQVariant(const QString &v);
    TestQVariant(const TestQVariant &a);
    bool hasName(void) const;        const QString &name(void) const;         void setName(const QString &name);
};%End
// TestQVariant.h#ifndef TestQVariant_h#define TestQVariant_h
#include <QtCore/QVariant>#include <QtCore/QString>
class TestQVariant : public QVariant{public:    TestQVariant(void)    {    }
    TestQVariant(const QVariant &v) :        QVariant(v)    {    }        TestQVariant(int v) :        QVariant(v)    {    }        TestQVariant(double v) :        QVariant(v)    {    }        TestQVariant(const QString &v) :        QVariant(v)    {    }
    TestQVariant(const TestQVariant &a) :        QVariant(a),        mName(a.mName)    {    }
    TestQVariant &operator=(const TestQVariant &a)    {        QVariant::operator=(a);        mName = a.mName;        return *this;    }        bool hasName(void) const    {        return !mName.isEmpty();    }        const QString &name(void) const    {        return mName;    }        void setName(const QString &name)    {        mName = name;    }    private:    QString mName;};
#endif

Is this related to the API version that QVariant is using? This is with Python 2.7, so it should default to '2'.  Is there some other name I need to use for the QVariant class to get this to work?  -Nate 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20130416/cf0c7fc6/attachment-0001.html>


More information about the PyQt mailing list