Qt Design Studio project import on Qt creator
-
I imported a Qt design studio project on Qt creator following the guide: https://doc.qt.io/qtdesignstudio/quick-converting-ui-projects.html
After the import of all the modules included Timeline I've tried to run the project.
The following errors appear:qrc:/qml/Cluster_Art.ui.qml:54:1: module "Data" is not installed
qrc:/qml/Cluster_Art.ui.qml:56:1: module "QtQuick.Studio.Effects" is not installed
qrc:/qml/Cluster_Art.ui.qml:55:1: module "QtQuick.Studio.Components" is not installedData is a directory under the Qt Design Studio project
Studio/Components is a directory under the Qt Design Studio project
Studio/Effects is a directory under the Qt Design Studio projectWhy Qt creator doesn't recognize them?
What I have to do?I'm a newbie please help me.
Regards
-
You have to add the import path for the imports in main.cpp.
Before calling setSource() you simply have to add:
view.engine->addImportPath("qrc:/qml/imports");We will adjust the documentation.
-
from PySide2.QtWidgets import QApplication, QMainWindow from PySide2.QtQuick import QQuickView from PySide2.QtCore import QUrl from imports import QtQuick app = QApplication([]) view = QQuickView() url = QUrl("Screen01.ui.qml") view.engine().addImportPath("imports") view.setSource(url) view.show() app.exec_()
This gives the following error:
module "Qt.SafeRenderer" is not installed
module "QtStudio3D" is not installed -
@Pratik-Tayshete I know its been a year now (I'm starting with qt / python only now).
What helped me was to set absolute path instead of qrc. Also it is a good to know what paths are known to the engine (QQmlEngine Class).
My test application came out of QtStudio 2.0 with internal Qt5 (Tools/QtDesignSstudion/qt5_design_studio_reduced_version). Although I'm not an expert it seems to me that the engine is trying to find the corresponding QML files. Name of the import (QtQuick.Studio.Effects) suggest location of those files (Tools/QtDesignStudio/qt5_design_studio_reduced_version/qml/QtQuick/Studio/Effects)
So when I changed the default code from project template to this:
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.addImportPath("D:/code/fworks/qtnew/6.1.1/mingw81_64/qml/") print(str(engine.importPathList())) # path = Path(__file__).resolve().parent / "main.qml" path = "main.qml" engine.load(os.fspath(path)) if not engine.rootObjects(): print('EE: Cannot get engine rootObjects') sys.exit(-1) sys.exit(app.exec_())
Suddenly it recognized the files and import worked (plus the 'print' line prints out all import paths known to engine).
I still struggle with makeing it run, but I assume problem is that QtStudio (installed via online installer) uses reduced Qt5 and I'm trying to use Qt6. Interestingly, if I point the path to Qt.6.1.1 directory it doesn't work either (but the import path is recognized, so this is a different problem).