I personally like your syntax a lot more than the C++-derived one. Reading the tutorial you posted, the C++ syntax indeed is quite baroque and confusing, while yours is pretty much understandable without much extra homework. Not that I necessarily would have sufficient insight to judge on the matter, but still. :-)

Since the effects of this syntax are quite localized and it doesn't prevent us from providing alternative means for supporting QML list properties if this would somehow turn out to be a bad idea, there wouldn't seem to be much risk for adopting this.

What are the allowed arguments for ListProperty? append, count, at, clear, like in QDeclarativeListProperty? Are these keyword arguments? If so, how are the arguments named currently?

Cheers,

ma.

On 08.12.2010 18:42, ext Hugo Parente Lima wrote:
Hi,

I did implement the support for QML list properties in PySide, but using a
different syntax than the used by C++[1].

I could mirror the C++ syntax on PySide but in my opinion the QML API to
export list properties is a bit bizarre, in essence you create a *read-only*
property that can be *written*, just non-sense to me.

I'll use the example in [1] to show my proposed syntax and a syntax based in
the C++ API to help you to compare both, the following code represents a
possible implementation mirroring the C++ syntax:

class PieChart (QDeclarativeItem):

     def __init__(self, parent = None):
         QDeclarativeItem.__init__(self, parent)
         self._slices = []

     def appendSlice(prop, _slice):
         _slice.setParentItem(prop.object)
         prop.object._slices.append(_slice)

     def getSlice(self):
         return QDeclarativeListProperty(PieSlice, self, None, appendSlice)

     slices = Property(QDeclarativeListProperty, getSlice)

Instead of create the getter for the property and return a "mysterious" object
that turn a read-only property into a writable one I simplified the syntax to
the following:

class PieChart (QDeclarativeItem):

     def __init__(self, parent = None):
         QDeclarativeItem.__init__(self, parent)
         self._slices = []

     def appendSlice(self, _slice):
         _slice.setParentItem(self)
         self._slices.append(_slice)

     slices = ListProperty(PieSlice, appendSlice)


This is already implemented, Qt.Declarative.ListProperty is a subclass of
QtCore.Property, so I would like to know your opinions about this API before
pushing it to mainline.

[1] http://cakebox.homeunix.net/doc/qt4/html/declarative-tutorials-extending-
chapter5-listproperties.html




_______________________________________________
PySide mailing list
[email protected]
http://lists.openbossa.org/listinfo/pyside

_______________________________________________
PySide mailing list
[email protected]
http://lists.openbossa.org/listinfo/pyside

Reply via email to