Skip to content

QmlEngineMixin

Sub classes

Name Children Inherits
QmlEngine
prettyqt.qml.qmlengine
Environment for instantiating QML components.
    QmlApplicationEngine
    prettyqt.qml.qmlapplicationengine
    Convenient way to load an application from a single QML file.

      Base classes

      Name Children Inherits
      JSEngineMixin
      prettyqt.qml.jsengine
      object
      builtins
      The base class of the class hierarchy.
      • type
      • async_generator
      • bytearray_iterator
      • bytearray
      • bytes_iterator
      • bytes
      • builtin_function_or_method
      • callable_iterator
      • PyCapsule
      • cell
      • classmethod_descriptor
      • ...

        ⋔ Inheritance diagram

        graph TD
          3784176072["qml.QmlEngineMixin"]
          3962672466["qml.JSEngineMixin"]
          3227531497["core.ObjectMixin"]
          2751680898["builtins.object"]
          3962672466 --> 3784176072
          3227531497 --> 3962672466
          2751680898 --> 3227531497
          2751680898 --> 3962672466
          2751680898 --> 3784176072

        🛈 DocStrings

        Bases: JSEngineMixin, _QmlEngineBase

        Source code in prettyqt/qml/qmlengine.py
        class QmlEngineMixin(qml.JSEngineMixin, _QmlEngineBase):
            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))
        

        :fa-brands-github: Show source on GitHub