proto-debuger/protoDebuger/main.cpp

39 lines
1.1 KiB
C++

#include <QApplication>
#include <QQmlApplicationEngine>
#include <QTextCodec>
#include <QByteArray>
#include "lua_wraper.h"
#include <QtWidgets/QApplication>
#include "sharedata.h"
#include "serialcontroller.h"
void RegisterQmlType(){
qmlRegisterType<ShareData>("ShareData", 1, 0, "Data");
}
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication app(argc, argv);
// TestLua();
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);
SerialController *pSerial = new SerialController();
QList<QextPortInfo> list = pSerial->GetPorts();
for(int i = 0 ;i < list.size();i++){
QTextCodec *codec = QTextCodec::codecForName("UTF-16");
QString string = codec->fromUnicode(list[i].portName.toUtf8());
qDebug()<<string;
}
RegisterQmlType();
return app.exec();
}