48 lines
1.3 KiB
C++
48 lines
1.3 KiB
C++
#include <QApplication>
|
|
#include <QQmlApplicationEngine>
|
|
#include <QTextCodec>
|
|
#include <QByteArray>
|
|
#include <QtWidgets/QApplication>
|
|
#include <QQuickView>
|
|
#include <QQmlComponent>
|
|
#include <QQmlContext>
|
|
#include <QtSerialPort/QSerialPort>
|
|
#include <QtSerialPort/QSerialPortInfo>
|
|
|
|
#include "sharedata.h"
|
|
#include "serialcontroller.h"
|
|
#include "lua_wraper.h"
|
|
|
|
|
|
ShareData gGlobal;
|
|
|
|
void RegisterQmlType(){
|
|
qmlRegisterSingletonInstance<ShareData>("ShareData", 1, 0, "DataWrap",&gGlobal);
|
|
}
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
|
QGuiApplication app(argc, argv);
|
|
|
|
QStringList comList;
|
|
const auto infos = QSerialPortInfo::availablePorts();
|
|
for (const QSerialPortInfo &info : infos) {
|
|
comList<<info.portName();
|
|
}
|
|
|
|
SerialController *pSerial = new SerialController();
|
|
|
|
QQuickView view;
|
|
view.setResizeMode(QQuickView::SizeRootObjectToView);
|
|
view.setSource(QUrl("qrc:/main.qml"));
|
|
view.setTitle ("多用途通信协议调试器,基于lua");
|
|
view.rootContext()->setContextProperty("DataWrap",&gGlobal);
|
|
|
|
view.show();
|
|
QObject *qmlObject = view.findChild<QObject*>("SerialSelect",Qt::FindChildOption::FindChildrenRecursively);
|
|
qmlObject->setProperty("comlist",comList);
|
|
|
|
return app.exec();
|
|
}
|