-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.cpp
More file actions
67 lines (46 loc) · 1.58 KB
/
Copy pathmain.cpp
File metadata and controls
67 lines (46 loc) · 1.58 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include "model.h"
#include "LyricModel.h"
#include "SongListModel.h"
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <qqmlengine.h>
#include <qqmlcontext.h>
#include <qqml.h>
#include <QtQuick/qquickitem.h>
#include <QtQuick/qquickview.h>
#include <QtWebEngine/qtwebengineglobal.h>
#include "QuickLayer.h"
SongModel newLstModel;
SongModel hotLstModel;
SongModel model;
PlayListModel playModel;
CLyricModel lyricModel;
CSongLstModel songLstModel;
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime()));
QtWebEngine::initialize();
//register C++ type CQuickLayer
qmlRegisterType<CQuickLayer>("com.mplayer", 1, 0, "Mplayer");
qmlRegisterType<CLyricLayer>("com.mplayer", 1, 0, "MLyric");
qmlRegisterType<CSongLstLayer>("com.mplayer", 1, 0, "MSonglst");
//QQuickView view;
//view.setResizeMode(QQuickView::SizeRootObjectToView);
//QQmlContext *ctxt = view.rootContext();
//ctxt->setContextProperty("myModel", &model);
//view.setSource(QUrl(QStringLiteral("qrc:/main.qml")));
//view.show();
//return app.exec();
QQmlApplicationEngine engine;
QQmlContext *ctxt = engine.rootContext();
ctxt->setContextProperty("myModel", &model);
ctxt->setContextProperty("playModel", &playModel);
ctxt->setContextProperty("lyricModel", &lyricModel);
ctxt->setContextProperty("songLstModel", &songLstModel);
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
if (engine.rootObjects().isEmpty())
return -1;
return app.exec();
}