diff --git a/protoDebuger/CMakeLists.txt b/protoDebuger/CMakeLists.txt index 2ebeecc..01c8166 100644 --- a/protoDebuger/CMakeLists.txt +++ b/protoDebuger/CMakeLists.txt @@ -21,12 +21,14 @@ set(HEADERS # 待预编译的cpp头文件 qserialproto.h globalvar.h serialcontroller.h + sharedata.h ) set(SOURCES # 待预编译的cpp代码 serialcontroller.cpp qserialproto.cpp globalvar.cpp + sharedata.cpp ) set(RESOURCES @@ -46,18 +48,25 @@ set (UIS ${QsswraperUI} ) -include(D:\\project\\c++qt\\qsswraper\\extserial\\src\\qextserialport.cmake) include(D:\\project\\c++qt\\qsswraper\\CMakeLists.txt) +include(D:\\project\\c++qt\\qsswraper\\extserial\\src\\qextserialport.cmake) QT5_WRAP_CPP(MOC ${SOURCES} ) # moc预编译代码 QT5_WRAP_CPP(MOCHEADER ${HEADERS} ) # moc预编译代码 QT5_ADD_RESOURCES(RCC ${RESOURCES}) # rcc生成资源cpp QT5_WRAP_UI(UIC ${UIS}) # uic生成ui_x.h -message("MOC " ${MOC} ${MOCHEADER}) -message("UIC " ${UIC}) -message("RCC " ${RCC}) -message("NO_MOC_SOURCES " ${NO_MOC_SOURCES}) + +FOREACH(list ${UIC}) + message("MOC " ${list} ) +ENDFOREACH(list) + +FOREACH(list ${MOC}) + message("MOC " ${list} ) +ENDFOREACH(list) +FOREACH(list ${NO_MOC_SOURCES}) + message("NO_MOC_SOURCES " ${list} ) +ENDFOREACH(list) add_executable(protoDebuger #最后需要参与链接生成的是 ${SOURCES} #1. 原先的cpp代码, diff --git a/protoDebuger/NetSelect.qml b/protoDebuger/NetSelect.qml index b0da97a..f2f2e77 100644 --- a/protoDebuger/NetSelect.qml +++ b/protoDebuger/NetSelect.qml @@ -108,6 +108,10 @@ Item { }else{ radioButton.checked = true } + + + + } } } diff --git a/protoDebuger/globalvar.h b/protoDebuger/globalvar.h index 6e0edb0..47641d8 100644 --- a/protoDebuger/globalvar.h +++ b/protoDebuger/globalvar.h @@ -19,7 +19,6 @@ public: private: SerialController *mSerial; - QSerialProto mProto; }; diff --git a/protoDebuger/main.cpp b/protoDebuger/main.cpp index 2d74204..cdcf995 100644 --- a/protoDebuger/main.cpp +++ b/protoDebuger/main.cpp @@ -1,12 +1,20 @@ #include #include +#include +#include #include "lua_wraper.h" +#include +#include "sharedata.h" +#include "serialcontroller.h" + +void RegisterQmlType(){ + qmlRegisterType("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")); @@ -17,5 +25,14 @@ int main(int argc, char *argv[]) }, Qt::QueuedConnection); engine.load(url); + SerialController *pSerial = new SerialController(); + QList 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()< controler -> proto -> listener */ using namespace std; diff --git a/protoDebuger/sharedata.cpp b/protoDebuger/sharedata.cpp new file mode 100644 index 0000000..a40f158 --- /dev/null +++ b/protoDebuger/sharedata.cpp @@ -0,0 +1,6 @@ +#include "sharedata.h" + +ShareData::ShareData(QObject *parent) : QObject(parent) +{ + +} diff --git a/protoDebuger/sharedata.h b/protoDebuger/sharedata.h new file mode 100644 index 0000000..47130e2 --- /dev/null +++ b/protoDebuger/sharedata.h @@ -0,0 +1,20 @@ +#ifndef SHAREDATA_H +#define SHAREDATA_H + +#include +#include + +class ShareData : public QObject +{ + Q_OBJECT +public: + explicit ShareData(QObject *parent = nullptr); + Q_INVOKABLE void getValFromQml(int v) { + qDebug() << "value from qml is :" << v; + emit valueFromCpp(456); + } +signals: + void valueFromCpp(int val); +}; + +#endif // SHAREDATA_H