[PyQt] How to have QML interpret a property as null (instead of undefined)?

Russell Warren russ at perspexis.com
Thu Oct 12 16:24:22 BST 2017

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20171012/adba0533/attachment.html>

More information about the PyQt mailing list