Exemplo n.º 1
0
    def _getProp(self, obj: QtCore.QObject) -> QtQml.QQmlProperty:
        """Get the QML property instance

        Parameters
        ----------
        obj:
            QObject to get property from

        Returns
        -------
        Property object

        Raises
        ------
        AttributeError
            The QObject does not have such a propery
        """
        p = QtQml.QQmlProperty(obj, self._name)
        if not p.isValid():
            raise AttributeError(f"no QML-defined property named {self._name}")
        return p
Exemplo n.º 2
0
    def _getProp(self, name: str) -> QtQml.QQmlProperty:
        """Get the QML property instance

        Parameters
        ----------
        name
            Property name

        Returns
        -------
        Property object

        Raises
        ------
        AttributeError
            The :py:attr:`instance_` does not have such a propery
        """
        p = QtQml.QQmlProperty(self.instance_, name, self._engine)
        if not p.isValid():
            raise AttributeError(f"'{type(self.instance_)}' has no property "
                                 f"'{name}'")
        return p