[PyQt] Small doc fix
Elvis Stansvik
elvstone at gmail.com
Sun May 8 16:54:54 BST 2016
2016-05-08 17:44 GMT+02:00 Elvis Stansvik <elvstone at gmail.com>:
> Hi Phil,
>
> A small fix for:
>
> http://pyqt.sourceforge.net/Docs/PyQt5/qt_properties.html
>
> would be to change:
>
> notify – the optional unbound notify signal. It is ignored by Python
>
> to
>
> notify – the optional unbound notify signal. Only needed if you
> want to use the property in QML property bindings
>
> since it seems I must use it if I want to use the property in QML
> property bindings, e.g:
>
> Window {
> color: machine.initializing ? "red" : "green"
> ...
> }
>
> or else I'll get errors like:
>
> QQmlExpression: Expression
> file:///home/estan/Projekt/orexplore/dev/src/orexplore.machine/orexplore/hmi/qml/main.qml:15:12
> depends on non-NOTIFYable properties: Machine::initializing
Correct me if I'm doing something else wrong of course :) The property
is defined like (only relevant parts shown):
class Machine(QObject):
initializingChanged = pyqtSignal(bool, arguments=['initializing'])
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._initializing = False
@pyqtProperty(bool)
def initializing(self):
return self._initializing
@initializing.setter
def initializing(self, initializing):
if initializing != self._initializing:
self._initializing = initializing
self.initializingChanged.emit(self._initializing)
and adding notify=initializingChanged to @pyqtProperty fixes the error.
Elvis
>
> Cheers,
> Elvis
More information about the PyQt
mailing list