#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QtQml>
// [1]
#include "Custom.h"
int main(int argc, char *argv[])
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
QGuiApplication app(argc, argv);
// [2]
Custom* _custom = new Custom;
QQmlApplicationEngine engine;
// [3]
engine.rootContext()->setContextProperty("Custom", _custom);
const QUrl url(QStringLiteral("qrc:/main.qml"));
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
&app, [url](QObject *obj, const QUrl &objUrl) {
if (!obj && url == objUrl)
QCoreApplication::exit(-1);
}, Qt::QueuedConnection);
engine.load(url);
return app.exec();
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
Qml_Use_C-template.zip (7个子文件)
Qml_Use_C-template
Custom.cpp 49B
Qml-TcpLink.pro.user 18KB
main.cpp 824B
qml.qrc 92B
main.qml 226B
Custom.h 234B
Qml-TcpLink.pro 739B
共 7 条
- 1
资源评论
Ley-S
- 粉丝: 25
- 资源: 48
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功