remove qml & use qwidget

This commit is contained in:
王劲鹏 2019-12-18 17:35:37 +08:00
parent ad04078f88
commit 001eb4a963
6 changed files with 26 additions and 44 deletions

View File

@ -1,4 +1,6 @@
QT += quick QT += \
quick \
widgets
CONFIG += c++11 CONFIG += c++11
@ -53,6 +55,7 @@ HEADERS += \
native/native_timer.h \ native/native_timer.h \
plugin/shader_plugin.h \ plugin/shader_plugin.h \
registry.h \ registry.h \
shader/layer.h \
shader/super_node.h \ shader/super_node.h \
shader/view_node.h \ shader/view_node.h \
template/singleton.h \ template/singleton.h \

View File

@ -1,26 +1,19 @@
#include <QApplication>
#include <QDialog>
#include <QFile> #include <QFile>
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QResource> #include <QResource>
#include <QTextStream>
#include "context_manager.h" #include "context_manager.h"
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QApplication app(argc, argv);
{
QGuiApplication app(argc, argv); QWidget *widget = new QWidget(nullptr, Qt::WindowType::Window);
widget->setWindowTitle(QString("Hello Doric"));
QQmlApplicationEngine engine; widget->resize(360, 640);
const QUrl url(QStringLiteral("qrc:/doric/main.qml")); widget->show();
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, }
&app, [url](QObject *obj, const QUrl &objUrl) {
if (!obj && url == objUrl)
QCoreApplication::exit(-1);
}, Qt::QueuedConnection);
engine.load(url);
{ {
QResource resource(":/doric/Snake.js"); QResource resource(":/doric/Snake.js");
QFile *file = new QFile(resource.fileName()); QFile *file = new QFile(resource.fileName());

View File

@ -1,23 +0,0 @@
import QtQuick 2.6
import QtQuick.Controls 2.13
import QtQuick.Window 2.2
Window {
visible: true
width: 360;
height: 640;
title: qsTr("Hello Doric");
StackView {
id: stack;
anchors.centerIn: parent;
initialItem: mainView;
width: 360;
height: 640;
}
Rectangle {
id: mainView;
color: "lightgreen";
}
}

View File

@ -1,6 +1,5 @@
<RCC> <RCC>
<qresource prefix="/doric"> <qresource prefix="/doric">
<file alias="main.qml">main.qml</file>
<file alias="doric-sandbox.js">../../doric-js/bundle/doric-sandbox.js</file> <file alias="doric-sandbox.js">../../doric-js/bundle/doric-sandbox.js</file>
<file alias="doric-lib.js">../../doric-js/bundle/doric-lib.js</file> <file alias="doric-lib.js">../../doric-js/bundle/doric-lib.js</file>
<file alias="Snake.js">../../doric-demo/bundle/src/Snake.js</file> <file alias="Snake.js">../../doric-demo/bundle/src/Snake.js</file>

10
doric/shader/layer.h Normal file
View File

@ -0,0 +1,10 @@
#ifndef LAYER_H
#define LAYER_H
#include "QWidget"
class Layer : public QWidget {
};
#endif // LAYER_H

View File

@ -1,11 +1,10 @@
#ifndef VIEW_NODE_H #ifndef VIEW_NODE_H
#define VIEW_NODE_H #define VIEW_NODE_H
#include <QDebug>
#include "context_holder.h" #include "context_holder.h"
using namespace std;
template <typename V>
class SuperNode; class SuperNode;
template <class T> template <class T>
@ -15,6 +14,7 @@ protected:
T view; T view;
private: private:
SuperNode *superNode;
QString *id; QString *id;
public: public: