Skip to content

QmlEngineMixin

Base classes

Name Children Inherits
JSEngineMixin
prettyqt.qml.jsengine

Subclasses

Class Module Description
QmlEngine prettyqt.qml.qmlengine
QmlApplicationEngine prettyqt.qml.qmlapplicationengine

⋔ Inheritance diagram

graph TD
  1473572315968["qml.QmlEngineMixin"]
  1473572333536["qml.JSEngineMixin"]
  1473299815024["core.ObjectMixin"]
  140713234304496["builtins.object"]
  1473572333536 --> 1473572315968
  1473299815024 --> 1473572333536
  140713234304496 --> 1473299815024

🛈 DocStrings

Bases: JSEngineMixin

Source code in prettyqt\qml\qmlengine.py
class QmlEngineMixin(qml.JSEngineMixin):
    def set_object_ownership(
        self,
        obj: core.QObject,
        mode: ObjectOwnershipStr | qml.QQmlEngine.ObjectOwnership,
    ):
        """Set the object ownership.

        Args:
            obj: object to set ownership for
            mode: object ownership to use
        """
        self.setObjectOwnership(obj, OBJECT_OWNERSHIP.get_enum_value(mode))

    def get_object_ownership(self, obj: core.QObject) -> ObjectOwnershipStr:
        """Return object ownership.

        Returns:
            object ownership
        """
        return OBJECT_OWNERSHIP.inverse[self.objectOwnership(obj)]

    def add_import_path(self, path: datatypes.PathType):
        self.addImportPath(os.fspath(path))

    def add_plugin_path(self, path: datatypes.PathType):
        self.addPluginPath(os.fspath(path))

    def get_plugin_paths(self) -> list[pathlib.Path]:
        return [pathlib.Path(p) for p in self.pluginPathList()]

    def get_import_paths(self) -> list[pathlib.Path]:
        return [pathlib.Path(p) for p in self.importPathList()]

    def set_base_url(self, url: str | core.QUrl):
        if isinstance(url, str):
            url = core.QUrl(url)
        self.setBaseUrl(url)

    def get_base_url(self) -> core.Url:
        return core.Url(self.baseUrl())

    def set_offline_storage_path(self, path: datatypes.PathType):
        self.setOfflineStoragePath(os.fspath(path))

get_object_ownership(obj: core.QObject) -> ObjectOwnershipStr

Return object ownership.

Source code in prettyqt\qml\qmlengine.py
def get_object_ownership(self, obj: core.QObject) -> ObjectOwnershipStr:
    """Return object ownership.

    Returns:
        object ownership
    """
    return OBJECT_OWNERSHIP.inverse[self.objectOwnership(obj)]

set_object_ownership(obj: core.QObject, mode: ObjectOwnershipStr | qml.QQmlEngine.ObjectOwnership)

Set the object ownership.

Parameters:

Name Type Description Default
obj QObject

object to set ownership for

required
mode ObjectOwnershipStr | ObjectOwnership

object ownership to use

required
Source code in prettyqt\qml\qmlengine.py
def set_object_ownership(
    self,
    obj: core.QObject,
    mode: ObjectOwnershipStr | qml.QQmlEngine.ObjectOwnership,
):
    """Set the object ownership.

    Args:
        obj: object to set ownership for
        mode: object ownership to use
    """
    self.setObjectOwnership(obj, OBJECT_OWNERSHIP.get_enum_value(mode))