I'm trying to setup Qt for Python development, this is my first time using Qt though and I'm struggling with some difficulties regarding Qml, can't manage to get it working properly.
So. When I first launch the Design tab of my blank main.qml file, this is what I get, a little buggy and tinny window with an alert letting me now that the item ("Window") could not be created:
I managed to solve this by changing my QML Emulation Layer from "use fallback QML emulation layer" to "Use QML emulation layer that is built with the selected Qt" on Tools>Options>QT Quick> Qt Quick Designer.
This fixes the issue with the Design mode. However, after solving this, when I try to compile and run my blank application (didn't code anything yet, it's just an empty Python/Qt Quick application preset), I get this error message on the application output:
QQmlApplicationEngine failed to load component
c:%5c(my project path)%5Cmain.qml: Network error
I'm 99% sure it must be a super dumb newbie mistake of mine, but I can't manage to get it solved so I come here, kindly asking for your wise knowledge and help x')
I'm currently running the latest version of Qt6, with pyside6 and python 3.10.0 on Windows 10.
Already tried reinstalling Qt (a lot of times), also tried with different Qt builds (Qt5.15/pyside2 and a few more). Also tried with different Qt application presets that doesn't require Python but I keep getting the same error message.
Edit: I encounter the issue no matter what's written in the QML, even a simple empty window ends up throwing the exception:
Python::
# This Python file uses the following encoding: utf-8
import os
from pathlib import Path
import sys
from PySide6.QtGui import QGuiApplication
from PySide6.QtQml import QQmlApplicationEngine
if __name__ == "__main__":
app = QGuiApplication(sys.argv)
engine = QQmlApplicationEngine()
engine.load(os.fspath(Path(__file__).resolve().parent / "main.qml"))
if not engine.rootObjects():
sys.exit(-1)
sys.exit(app.exec_())
QML::
import QtQuick
import QtQuick.Window
Window {
width: 640
height: 480
visible: true
title: qsTr("Hello World")
}
Maybe I'm doing something wrong when building the application (I'm just trying Ctrl+R) or something is not properly setup on tools>options, I don't know. Just keep in mind I've never used Qt before so the mistake may be very dumb.