qt - qml qt 5.12 在一个程序中使用模块 controls1 和 controls2
问题描述
我不能在一个程序中使用 QtQuick.Controls 1.2 和 QtQuick.Controls 2.12。尽管在 Qt 5.10 中这行得通。现在我在加载 main.qml 时收到此消息: “qrc:/MyButton.qml 2 module QtQuick.Controls 2.12 is not installed”
Qt 5.12。在 macOS 上构建 ios 或 ios 模拟器。
轮廓
QT += quick quickcontrols2
CONFIG += c++11
DEFINES += QT_DEPRECATED_WARNINGS
SOURCES += \
main.cpp
RESOURCES += qml.qrc
QML_IMPORT_PATH =
QML_DESIGNER_IMPORT_PATH =
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
main.qml
import QtQuick 2.9
import QtQuick.Window 2.2
import QtQuick.Controls 1.2
Window {
visible: true
Button {
id: button1
text: "Controls 1 button"
anchors.centerIn: parent
}
MyButton {
text: "Controls 2 button"
anchors {
top: button1.bottom
horizontalCenter: parent.horizontalCenter
}
}
}
我的按钮.qml
import QtQuick 2.9
import QtQuick.Controls 2.12
Button {
}
主文件
#include <QGuiApplication>
#include <QQmlApplicationEngine>
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
if (engine.rootObjects().isEmpty())
return -1;
return app.exec();
}
qml.qrc
<RCC>
<qresource prefix="/">
<file>main.qml</file>
<file>MyButton.qml</file>
</qresource>
</RCC>
也许需要遵循一些限制或规则才能使其发挥作用?如果仅使用 Constools 1.2 或仅使用 Constols 2.12,则 main.qml 加载成功。
ps Build on windows for windows 和 build on windows for android 工作正常。问题仅在于 ios/ios 模拟器的 mac os 上构建。
解决方案
推荐阅读
- c# - C#浮点到二进制字符串,反之亦然
- beautifulsoup - 从谷歌搜索中使用 csv 文件中的多个搜索词检索 url。当我运行上述代码时,csv文件为空
- python - 为什么我的脚本不能始终如一地检测电子邮件正文中的内容?
- python - 来自 ipywidget 的组合框小部件不起作用
- edi - 可用性 270 资格请求始终返回 AAA*N**79*C~ 错误
- c - 2 C 中函数中的 while 循环
- dart - 在 Dart 中混合初始化器和构造器主体
- javascript - 点击时图片不显示在灯箱模块中
- javascript - JS puppeteer 使用 for 循环遍历链接
- vue.js - 我有一个 vue 组件不呈现数据的问题