[PyQt] How to have QML interpret a property as null (instead of undefined)?
oliver
oliver.schoenborn at gmail.com
Thu Oct 12 17:27:49 BST 2017
Is this a documented technique? If not, I would avoid it. Use only the
documented way of doing this, and if none is documented, there is likely a
reason that the feature is not available. In that case, find and understand
the reason, and fix your design accordingly.
On Thu, 12 Oct 2017 at 11:25 Russell Warren <russ at perspexis.com> wrote:
> Solution found: Returning a freshly instantiated QObject() does the
> trick. QML interprets this as a null. ie:
>
> @pyqtProperty(QVariant, notify = publicPropertyChanged)#'QDateTime')
> def my_date(self):
> if self._my_date is None:
> return QObject() # QML interprets this as null
> return QDateTime(self._my_date) # no PyQt autoconvert for
> datetime->QVariant
> _______________________________________________
> PyQt mailing list PyQt at riverbankcomputing.com
> https://www.riverbankcomputing.com/mailman/listinfo/pyqt
--
Oliver
My StackOverflow contributions
My CodeProject articles
My Github projects
My SourceForget.net projects
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20171012/330e2cec/attachment.html>
More information about the PyQt
mailing list