On Thu, 12 Aug 2010 17:37:12 -0300
Marcelo Lira <[email protected]> wrote:
> According to PSEP 101[1] a constructor for QObject and derived classes
> should be able to set Qt properties through named arguments.
> In practical terms to set the Qt property "objectName" to "foobar" one
> should do:
> 
> obj = QObject(objectName='foobar')
> 
> This can be done in a more verbose way:
> 
> obj = QObject()
> obj.setProperty('objectName', 'foobar')
> 
> You can set dynamic properties, i.e. not previously declared on the
> QObject derived object:
> 
> obj = QObject()
> obj.setProperty('myNumber', 123)

[snip]

I agree with Matti that this should be a separate PEP if you plan to
pursue it.

As I understand it you want to allow:

    obj = QObject(my_new_property="Hello")

on the basis that the user can do this at any time:

    obj.setProperty("my_new_property", "Hello")

I am opposed to this.

At the moment only existing properties can be set in the constructor,
which means that typos and other errors result in an exception which I
think is good.

This means that if someone wants to add a new property they must use
QObject.setProperty(), in other words they must do so explicitly, which
I think is a good thing.

-1


-- 
Mark Summerfield, Qtrac Ltd, www.qtrac.eu
    C++, Python, Qt, PyQt - training and consultancy
        "Advanced Qt Programming" - ISBN 0321635906
            http://www.qtrac.eu/aqpbook.html

-- 
Mark Summerfield, Qtrac Ltd, www.qtrac.eu
    C++, Python, Qt, PyQt - training and consultancy
        "Advanced Qt Programming" - ISBN 0321635906
            http://www.qtrac.eu/aqpbook.html
_______________________________________________
PySide mailing list
[email protected]
http://lists.openbossa.org/listinfo/pyside

Reply via email to