forked from AutumnEarly/QtQuickSimplePlayer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
38 lines (31 loc) · 1.24 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include "framelesswindow.h"
#include "imagecolor.h"
#include "downloadtask.h"
#include "musicdownload.h"
#include "desktoplyric.h"
#include "qctool.h"
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
const QUrl url(u"qrc:/musicPlayerDemo/main.qml"_qs);
qmlRegisterType<FramelessWindow>("qc.window",1,0,"FramelessWindow");
qmlRegisterType<ImageColor>("qc.window",1,0,"ImageColor");
qmlRegisterType<MusicDownload>("qc.window",1,0,"MusicDownload");
qmlRegisterType<DownloadTask>("qc.window",1,0,"DownloadTask");
qmlRegisterType<DesktopLyric>("qc.window",1,0,"DesktopLyric");
QCTool qcTool;
// 将 QCTool 对象注册为 QML 上下文属性
engine.rootContext()->setContextProperty("QCTool", &qcTool);
QCoreApplication::setOrganizationName("appEarlyAutumn.org");
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();
}