Skip to content

Example for QML and fbs is missing #6

Closed
@alinnert

Description

@alinnert

I'm coming from the Book "Python and Qt - The Best Parts". I don't know if this is the right spot for this issue, but it is mainly about the book.

This book uses the examples in this repo. There's one example how to use QML with PyQt. Then later on fbs is being added to the stack. Now I wanted to combine both but fell on my nose doing so.

If you use QML like in the example and add fbs to it, the frozen app won't do anything. It starts a UI process but doesn't open a window. In that situation you have to kill that process, or you can't freeze the project again, because the .exe is still running in the background. By fiddling around I found what the problem is:

The frozen app has no copy of the .qml file. So, it can't load it. You need to move it into the src/main/resources/base folder and load it like so:

engine = QQmlApplicationEngine()
engine.load(app_context.get_resource('window.qml'))

Freezing the project like this makes the frozen executable run as expected.

Yes, you can combine the information from the book to come to this solution. But I think it should be mentioned explicitly that you have to use .get_resource() for .qml files, too.

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