Basic QQmlApplicationEngine in PySide6
-
@eyllanesc Thanks for the quick response, however this doesn't seem to work either. I also tested my original qml on PySide2 and it also doesn't work. I think I'm missing something more fundamental about how to load qml with qqmlapplicationengine.
-
Hi and welcome to devnet,
Might be a silly question but are you sure about your QML file path ?
-
@SGaist
The QUrl I am passing looks like this:PySide6.QtCore.QUrl('file:///C:/Users/alan/PycharmProjects/sozu-tmt/sozu/main.qml')
The URI scheme with a Windows path name looks correct to me. I'm looking at trying to pass this in as a qresource in python which should move path lookup concerns to the point that resources are built.
-
@eyllanesc Ok, that's good to know. I changed toolbar and statusbar to header and footer, and I've left out the minimum width and height for now. I haven't seen any docs about dropping the version from the import; the docs you linked have versioned imports as well. Could you provide a bit more clarity on this one?
-
@eyllanesc I made changes to the properties that I am using, as noted in the other thread. I haven't seen any doc that removes versions from the import line. After reviewing the documentation you linked, this is what I have.
I haven't gotten an actual error message about the qml load, it just doesn't get loaded. Not sure if that is because of bad qml or a qml path issue although I'm pursuing both as possible issues.
Thank you for your time and assistance!
import QtQuick 2.12 import QtQuick.Controls 2.12 ApplicationWindow { id: root visible: true title: qsTr("MyTitle") menuBar: MenuBar {} header: ToolBar {} footer: TabBar {} StackView { anchors.fill: parent } }
-
@sunkeita 1) You have not received any error message because as soon as your qml is launched, the interpreter cannot understand it so no rootObjects is built and therefore
sys.exit(-1)
is executed, 2) I recommend you check the blog of Qt since there they point out the new modifications that come with Qt6 that are not yet documented, unfortunately, at this moment I cannot find the link but when I find it I will give it to you but you can read this: https://jbbgameich.github.io/qt/2020/05/18/compiled-qml.html 3) If you want to get the warnings then use qmlscene:qmlscene.exe main.qml
-
@sunkeita See https://wiki.qt.io/New_Features_in_Qt_6.0 in seccion QML:
Qt QML
- The QML import and versioning system has been overhauled:
- Version numbers are optional in the QML language. An import without any version number imports the latest version of the module. An import with only a major version number imports the module with specified major version and the latest minor version.
- QML supports "auto" imports: Instead of specifying a version number, one can write import <module> auto. In that case the imported module is imported in the same version as the importing module.
- The QML import and versioning system has been overhauled:
-
@eyllanesc Thanks so much! On a lark I decided to try running this on my linux machine, and it worked just fine. I will try using qmlscene on my windows machine to find the errors there. I opened this thread to ensure that I was using QQmlApplicationEngine correctly, this issue is resolved.
Thanks again :)