I have another problem with qml and Pyside6. On Windows, I have this two files in the same directory and I am using Python 3.9.1. If I run this hello world I always have Network error and I don't see the QML component in the window
hello.qml file
import QtQuick 2.0
Rectangle {
width: 200
height: 200
color: "green"
Text {
text: "Hello world"
anchors.centerIn: parent
}
TextInput {
id: textInput1
x: 60
y: 112
width: 80
height: 20
text: qsTr("Introduzca texto")
font.pixelSize: 12
}
}
hello_qml.py file
import sys
from pathlib import Path, WindowsPath
from PySide6.QtWidgets import QApplication
from PySide6.QtQuick import QQuickView
from PySide6.QtCore import QUrl
app = QApplication(sys.argv)
qml_file = str(Path(__file__).parents[0] / 'hello.qml')
# qml_file = str(WindowsPath(__file__).parents[0] / 'hello.qml')
print(f'qml file = {qml_file}')
url = QUrl(qml_file)
view = QQuickView()
view.setSource(url)
view.show()
sys.exit(app.exec_())