6 changed files with 72 additions and 29 deletions
@ -0,0 +1,14 @@ |
|||
#include "app.h" |
|||
#include <qdebug.h> |
|||
App::App(QObject *parent): QObject (parent) |
|||
{ |
|||
|
|||
} |
|||
|
|||
App::~App(){} |
|||
|
|||
void App::loadQml() |
|||
{ |
|||
m_engine->load(""); |
|||
m_engine->load("qrc:/main.qml"); |
|||
} |
@ -0,0 +1,21 @@ |
|||
#ifndef APP_H |
|||
#define APP_H |
|||
#include <QObject> |
|||
#include <QQmlApplicationEngine> |
|||
|
|||
class App: public QObject |
|||
{ |
|||
|
|||
Q_OBJECT |
|||
public: |
|||
App(QObject* parent = Q_NULLPTR); |
|||
~App(); |
|||
|
|||
Q_INVOKABLE void loadQml(); |
|||
void setEngine(QQmlApplicationEngine *engine) { m_engine = engine; } |
|||
|
|||
private: |
|||
QQmlApplicationEngine* m_engine; |
|||
}; |
|||
|
|||
#endif // APP_H
|
@ -1,25 +1,19 @@ |
|||
#include <QGuiApplication> |
|||
#include <QQmlApplicationEngine> |
|||
#include <QQmlContext> |
|||
#include "app.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); |
|||
|
|||
QQmlApplicationEngine engine; |
|||
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); |
|||
|
|||
engine.load("qrc:/main.qml"); |
|||
App appy; |
|||
appy.setEngine(&engine); |
|||
engine.rootContext()->setContextProperty("app",&appy); |
|||
|
|||
return app.exec(); |
|||
} |
|||
|
@ -1,10 +1,21 @@ |
|||
import QtQuick 2.13 |
|||
import QtQuick.Window 2.13 |
|||
import "./SepantaUiKit/SKBtn" |
|||
import QtQuick.Window 2.11 |
|||
|
|||
Window { |
|||
width: 1700 |
|||
height: 900 |
|||
id: window |
|||
width: 1600 |
|||
height: 800 |
|||
visible: true |
|||
title: "SepantaUiKit" |
|||
color: "black" |
|||
|
|||
Shortcut { |
|||
sequence: "F5" |
|||
onActivated: { |
|||
window.close() |
|||
app.loadQml() |
|||
} |
|||
} |
|||
} |
|||
|
Loading…
Reference in new issue