[PyQt] Re: Add "user" property to a widget
Arve Knudsen
arve.knudsen at gmail.com
Wed Sep 10 12:44:23 BST 2008
Thanks, pyqtProperty was just the thing!
Arve
On Wed, Sep 10, 2008 at 11:58 AM, Alberto Berti <alberto at metapensiero.it> wrote:
>>>>>> "Arve" == Arve Knudsen <arve.knudsen at gmail.com> writes:
>
> Arve> I need to have a "user" property for a widget, so it can be
> Arve> fetched via its metaObject().userProperty(). This is
> Arve> required since the convention in Qt is to designate a "user"
> Arve> property of a widget for editing purposes (e.g., text() for
> Arve> QLineEdit). Now that I've explained my use case, how can I
> Arve> can define such a property in PyQt :)
>
> I know only QDataWidgetMapper that looks for the user prop but just
> when the property name isn't specified in the binding operation.
> However, i think since pyqt 4.4.4, the pyqtproperty decorator has a
> parameter for it:
>
> >>> from PyQt4.QtCore import pyqtProperty
> >>> help(pyqtProperty)
> Help on class pyqtProperty in module PyQt4.QtCore:
>
> class pyqtProperty(__builtin__.property)
> | pyqtProperty(type, fget=None, fset=None, freset=None, fdel=None, doc=None
> | designable=True, scriptable=True, stored=True, user=False)
> | -> property attribute
> |
> | type is the name of a C++ type that be passed to QVariant.nameToType().
> | freset is a function for resetting an attribute to its default value.
> | designable sets the DESIGNABLE flag (the default is True for writable
> | properties and False otherwise).
> | scriptable sets the SCRIPTABLE flag.
> | stored sets the STORED flag.
> | user sets the USER flag.
> | The other parameters are the same as those required by the standard Python
> | property type. Properties defined using pyqtProperty behave as both Python
> | and Qt properties.
>
> _______________________________________________
> PyQt mailing list PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
More information about the PyQt
mailing list