Error is not an attribute of QQuickView
-
Hello,
I'm migrating a Python script from Qt5 to Qt6.
But I'm facing to an error where I don't find a solution.view = QQuickView() view.setResizeMode(QQuickView.ResizeMode.SizeRootObjectToView) view.setTitle(app.translate("app", "Welcome")) ... current_path = os.path.abspath(os.path.dirname(__file__)) qml_file = os.path.join(current_path, "mw-ui.qml") view.setSource(QUrl.fromLocalFile(qml_file)) if view.status() == QQuickView.Error: for error in view.errors(): print(error.description()) sys.exit(-1) view.show()
I get:
if view.status() == QQuickView.Error: AttributeError: type object 'QQuickView' has no attribute 'Error'. Did you mean: 'errors'?
However, this is what is exposed in https://doc-snapshots.qt.io/qtforpython-6.5/examples/example_qml_signals_pytoqml1.html
I use pyqt6 6.4
-
Hello,
I'm migrating a Python script from Qt5 to Qt6.
But I'm facing to an error where I don't find a solution.view = QQuickView() view.setResizeMode(QQuickView.ResizeMode.SizeRootObjectToView) view.setTitle(app.translate("app", "Welcome")) ... current_path = os.path.abspath(os.path.dirname(__file__)) qml_file = os.path.join(current_path, "mw-ui.qml") view.setSource(QUrl.fromLocalFile(qml_file)) if view.status() == QQuickView.Error: for error in view.errors(): print(error.description()) sys.exit(-1) view.show()
I get:
if view.status() == QQuickView.Error: AttributeError: type object 'QQuickView' has no attribute 'Error'. Did you mean: 'errors'?
However, this is what is exposed in https://doc-snapshots.qt.io/qtforpython-6.5/examples/example_qml_signals_pytoqml1.html
I use pyqt6 6.4
@YvesB
You quote a reference to PySide documentation yet say you use PyQt. They are different. And I suspect in this area where I think the issue will be in the changes which came in Qt enum specifiers, which did indeed change from Qt5 to Qt6 in Python.Error
is aStatus
. Although I am not sure exactly what you will need to change it to, but something likeQQuickView.Status.Error
will be required now I think in Python. And may vary from PySide to PyQt. -
Hello,
I'm migrating a Python script from Qt5 to Qt6.
But I'm facing to an error where I don't find a solution.view = QQuickView() view.setResizeMode(QQuickView.ResizeMode.SizeRootObjectToView) view.setTitle(app.translate("app", "Welcome")) ... current_path = os.path.abspath(os.path.dirname(__file__)) qml_file = os.path.join(current_path, "mw-ui.qml") view.setSource(QUrl.fromLocalFile(qml_file)) if view.status() == QQuickView.Error: for error in view.errors(): print(error.description()) sys.exit(-1) view.show()
I get:
if view.status() == QQuickView.Error: AttributeError: type object 'QQuickView' has no attribute 'Error'. Did you mean: 'errors'?
However, this is what is exposed in https://doc-snapshots.qt.io/qtforpython-6.5/examples/example_qml_signals_pytoqml1.html
I use pyqt6 6.4
-