[PyQt] property support?

Phil Thompson phil at riverbankcomputing.co.uk
Fri Aug 17 19:04:43 BST 2007


On Friday 17 August 2007, Diez B. Roggisch wrote:
> Phil Thompson schrieb:
> > On Friday 17 August 2007, Diez B. Roggisch wrote:
> >> Hi,
> >>
> >> is there any existing or planned property-support? I've got a class that
> >> essentially looks like this:
> >>
> >> class Foo {
> >> public:
> >>     SomeType Name[Size];
> >> };
> >>
> >>
> >> So the Name-property is part of the public API. I'd like to access that
> >> using
> >>
> >> foo_instance.Name
> >>
> >> instead of introducing a getter/setter-pair. Any suggestions?
> >
> > http://www.riverbankcomputing.com/Docs/sip4/sipref.html#getcode
>
> Great. I searched the docs for "property", but that wasn't mentioned
> around %GetCode/%SetCode.
>
> However utilizing it, I stumbled over the following error:
>
> sip: irr::video::SMaterial::TextureWrap has an unsupported type
>
>
> The declaration looks like this (for now I don't care about setting, but
> I stubbed it to make sure that's not the problem cause)
>
>        //! Texture Clamp Mode
>        irr::video::E_TEXTURE_CLAMP *TextureWrap;
> %GetCode
> if(sipCpp && *sipCpp) {
>    sipPy = PyTuple_New(MATERIAL_MAX_TEXTURES);
>    irr::video::E_TEXTURE_CLAMP *tw = *(irr::video::E_TEXTURE_CLAMP
> **)sipCpp;
>    const enumType *sipFindMappedType("irr::video::E_TEXTURE_CLAMP");
>    for(int i = 0; i < MATERIAL_MAX_TEXTURES; i++) {
>      PyTuple_SetItem(sipPy, sipConvertFromNamedEnum(tw[i], enumType));
>    }
>   } else {
>    sipPy = Py_None;
>   }
> %End
> %SetCode
> sipCpp = 0;
> %End
>
>
> E_TEXTUR_CLAMP is your run-off-the-mill enumeration type. Any
> suggestions why that fails?

I'll need a complete .sip file. However I wont be able to look at it for about 
a week.

BTW, if E_TEXTURE_CLAMP is an enum then its Python type object is 
sipEnum_irr_video_E_TEXTURE_CLAMP. Alternatively you can use 
sipFindNamedEnum() - but not sipFindMappedType().

Phil


More information about the PyQt mailing list