我想将一些 qml 复制到我的构建目录中。
\n在 中.pro,我添加:
copydata.commands = $(COPY_DIR) \\"$$PWD/plugins\\" \\"$$DESTDIR/plugins\\"\nRun Code Online (Sandbox Code Playgroud)\n\n但是当我构建项目时,出现copydata错误。\n错误消息是:
\n\n\nxcopy /s /q /y /i\n "E:/myproject/src/plugins"\n "E:/myproject/bin/debug/plugins"\n 参数数量无效
\n
但是,我把命令复制到cmd,就可以了。
\n\n有谁知道 \xef\xbc\x9f 出了什么问题
\n当我用Qt.createComponent动态创建组件时,stutas总是Component.error但我无法理解原因.
我这样用过:
Rectangle{
function loadTest(){
function finishCreation() {
if (component.status === Component.Ready) {
console.log("ready")
} else if (component.status === Component.Error) {
// Error Handling
console.log("Error loading component:", component.errorString());
}
}
var component = Qt.createComponent("MyPage.qml");
console.log(component.status)
console.log("Error loading component:", component.errorString());
component.statusChanged.connect(finishCreation);
if (component.status === Component.Ready) {
var button = component.createObject(container);
console.log("ready")
}
}
Component.onCompleted: {
console.log("Completed Running!")
loadTest()
}
}
Run Code Online (Sandbox Code Playgroud)
如果文件MyPage.qml中不存在qrc,则错误为
qrc:/MyPage.qml:-1找不到文件"
如果我设置完整路径MyPage.qml,我得到一个Network error.
当我将SeriesSelectionPage.qml文件添加到资源文件时,它可以工作.但它不应该是动态的吗?
我只是想找到一个QML文件并在应用程序执行时动态加载它,以便应用程序可以根据用户操作加载不同的QML.
谁知道怎么做?我要疯了.