Skip to content

Importing QtGui silently imports QtWidgets #536

Description

@OpenNingia

In qtpy/QtGui.py there is this line:

from PySide6.QtWidgets import QFileSystemModel

I found this occurrence but maybe there are other ones.

which silently imports QtWidget. I understand it's there for backwards compatibility, but this causes some severe headache for some use cases (i.e. shipping a QML app on Android, the app crash because it doesn't bundle QtWidget binary library in the apk).

Please add an escape hatch to avoid importing QtWidgets inside QtGui.

Suggestion:

    def __getattr__(name):
        if name == "QFileSystemModel":
            from PySide6.QtWidgets import QFileSystemModel
            return QFileSystemModel
        raise AttributeError(f"module {__name__!r} has no attribute {name!r}")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions