[PySide] Purpose of the Notify kwarg in QtCore.Property

Tony Barbieri greatrgb at gmail.com
Wed Oct 10 21:50:00 CEST 2012


Right, but it doesn't seem to be emitting when I change the value of pp.
 If I have to manually emit it in the set method of the Property, what is
the point if it in the Property creation?

Thanks!

-tony

On Wed, Oct 10, 2012 at 3:36 PM, Hugo Parente Lima
<hugo.lima at openbossa.org>wrote:

> On Wednesday, October 10, 2012 02:28:31 PM Tony Barbieri wrote:
> > Hello,
>
> It's a signal that you must emit to notify others that your property
> changed,
> QML uses this signal a lot.
>
> > I am trying to figure out what the notify kwarg does in the
> QtCore.Property
> > command.  I thought that it would emit a signal whenever a Property
> > changes, but it doesn't seem to be doing anything.  I was trying it with
> > the following code:
> >
> > from PySide import QtCore
> >
> > @QtCore.Slot(int)
> > def updated(val):
> >     print 'Updated!!'
> >
> > class MyObject(QtCore.QObject):
> >     def __init__(self, startval=42):
> >         QtCore.QObject.__init__(self)
> >         self.ppval = startval
> >
> >     def set_pp(self, val):
> >         self.ppval = val
> >
> >     def get_pp(self):
> >         return self.ppval
> >
> >     pp_changed = QtCore.Signal(int)
> >     pp = QtCore.Property(int, get_pp, set_pp, notify=pp_changed)
> >
> > obj = MyObject()
> > obj.pp_changed.connect(updated)
> > obj.pp = 47
> > print obj.pp
> >
> > I could just have the pp_changed emit within set_pp but my understanding
> is
> > that this is a shortcut to not have to add that line.
> >
> > Thanks!
>



-- 
-tony
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/pyside/attachments/20121010/ec6d4b3e/attachment.html>


More information about the PySide mailing list