Skip to content

Example for QML and fbs is missing #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
alinnert opened this issue Nov 11, 2019 · 1 comment
Closed

Example for QML and fbs is missing #6

alinnert opened this issue Nov 11, 2019 · 1 comment

Comments

@alinnert
Copy link

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.

@mherrmann
Copy link
Collaborator

Thank you Andreas. I'll add a note about this to the book.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants