On Friday 08 April 2011 15:12:05 Ken Allen wrote: > I recently tried to make creating QDeclarativeItem types with properties > and such easier to write by using a metaclass. However, even though my > metaclass inherited from Shiboken.ObjectType and called > Shiboken.ObjectType.__new__ to do the real work registering the type with > QtDeclarative.qmlRegisterType failed with 'A shiboken-based python type > expected, got Meta' where Meta is the name of my metaclass. > > I can see why you would do this, but metaclasses allow for the nicest > syntax for autogenerating properties and the restriction seems a little, > well, restrictive. Would it be possible to relax this slightly and allow > classes whose metaclasses inherit from Shiboken.ObjectType to be > registered? This would greatly improve the metaprogramming possiblities > for PySide. > > Here's what my end goal was: > > class MyType(AutoQItem): > property1 = AutoProp(str) > property2 = AutoProp(int, default=10) > > etc... > > The resulting class would have fully function properties similar to those > in the AutoQObject example in the wiki, but with a much nicer syntax for > declaring them.
This is a PySide bug, and it's easy to fix, just change the line 107 of
pysideqmlregistertype.cpp from:
if (pyObj->ob_type != &SbkObjectType_Type) {
to
if (PyType_IsSubType(pyObj->ob_type, (PyTypeObject*)&SbkObjectType_Type))
{
I didn't this right now because I need a proper unit test before merging this
into mainline, if you could write one I can merge it ASAP, anyway I filed a
bug report[1], so this issue will not be forget.
[1] http://bugs.pyside.org/show_bug.cgi?id=825
> Ken Allen
> Software Engineer
> Scytale, Inc.
>
> ________________________________
> This e-mail from Scytale Inc and any attachments to it are confidential to
> the intended recipient and may also be privileged or controlled by U.S.
> export control laws and regulations. No technical data, information or
> other items provided by Scytale Inc in connection with this email shall be
> shared or provided to any foreign persons, entities, or subsidiaries
> without the expressed written authorization of Scytale Inc. If you have
> received it in error please notify the sender and delete it from your
> system. If you are not the intended recipient you must not copy it or use
> it for any purpose nor disclose or distribute its contents to any other
> person.
>
> All communications may be subject to interception or monitoring for
> operational and/or security purposes. Please rely on your own virus
> checking as the sender cannot accept any liability for any damage arising
> from any bug or virus infection.
--
Hugo Parente Lima
INdT - Instituto Nokia de Tecnologia
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ PySide mailing list [email protected] http://lists.pyside.org/listinfo/pyside
