no message

master
zcy 2021-04-11 11:28:04 +08:00
parent 2ef2a1e2d2
commit 065588efd5
9 changed files with 72 additions and 16 deletions

View File

@ -21,12 +21,14 @@ set(HEADERS # 待预编译的cpp头文件
qserialproto.h qserialproto.h
globalvar.h globalvar.h
serialcontroller.h serialcontroller.h
sharedata.h
) )
set(SOURCES # 待预编译的cpp代码 set(SOURCES # 待预编译的cpp代码
serialcontroller.cpp serialcontroller.cpp
qserialproto.cpp qserialproto.cpp
globalvar.cpp globalvar.cpp
sharedata.cpp
) )
set(RESOURCES set(RESOURCES
@ -46,18 +48,25 @@ set (UIS
${QsswraperUI} ${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\\CMakeLists.txt)
include(D:\\project\\c++qt\\qsswraper\\extserial\\src\\qextserialport.cmake)
QT5_WRAP_CPP(MOC ${SOURCES} ) # moc QT5_WRAP_CPP(MOC ${SOURCES} ) # moc
QT5_WRAP_CPP(MOCHEADER ${HEADERS} ) # moc QT5_WRAP_CPP(MOCHEADER ${HEADERS} ) # moc
QT5_ADD_RESOURCES(RCC ${RESOURCES}) # rcccpp QT5_ADD_RESOURCES(RCC ${RESOURCES}) # rcccpp
QT5_WRAP_UI(UIC ${UIS}) # uicui_x.h QT5_WRAP_UI(UIC ${UIS}) # uicui_x.h
message("MOC " ${MOC} ${MOCHEADER})
message("UIC " ${UIC}) FOREACH(list ${UIC})
message("RCC " ${RCC}) message("MOC " ${list} )
message("NO_MOC_SOURCES " ${NO_MOC_SOURCES}) 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 #最后需要参与链接生成的是 add_executable(protoDebuger #最后需要参与链接生成的是
${SOURCES} #1. cpp ${SOURCES} #1. cpp

View File

@ -108,6 +108,10 @@ Item {
}else{ }else{
radioButton.checked = true radioButton.checked = true
} }
} }
} }
} }

View File

@ -19,7 +19,6 @@ public:
private: private:
SerialController *mSerial; SerialController *mSerial;
QSerialProto mProto; QSerialProto mProto;
}; };

View File

@ -1,12 +1,20 @@
#include <QApplication> #include <QApplication>
#include <QQmlApplicationEngine> #include <QQmlApplicationEngine>
#include <QTextCodec>
#include <QByteArray>
#include "lua_wraper.h" #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[]) int main(int argc, char *argv[])
{ {
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication app(argc, argv); QApplication app(argc, argv);
// TestLua(); // TestLua();
QQmlApplicationEngine engine; QQmlApplicationEngine engine;
const QUrl url(QStringLiteral("qrc:/main.qml")); const QUrl url(QStringLiteral("qrc:/main.qml"));
@ -17,5 +25,14 @@ int main(int argc, char *argv[])
}, Qt::QueuedConnection); }, Qt::QueuedConnection);
engine.load(url); 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(); return app.exec();
} }

View File

@ -77,17 +77,16 @@ ApplicationWindow {
width: parent.width width: parent.width
height:60 height:60
onClicked: { onClicked: {
console.log("shit") uart_choose.visible = false
net_choose.visible = false
proto_debug.visible = true
} }
background: Image { background: Image {
anchors.fill: parent anchors.fill: parent
source: "qrc:///res/proto.svg" source: "qrc:///res/proto.svg"
} }
onPressed:{
uart_choose.visible = false
net_choose.visible = false
proto_debug.visible = true
}
} }
Text { Text {
text: qsTr("协议调试") text: qsTr("协议调试")
@ -104,16 +103,17 @@ ApplicationWindow {
} }
NetSelect{ NetSelect{
objectName: net_choose id: net_choose
} }
Rectangle { Rectangle {
objectName: proto_debug id: proto_debug
width: parent.width - 80 width: parent.width - 80
height: parent.height height: parent.height
color: "grey" color: "grey"
visible: false visible: false
} }
} }
} }

View File

@ -43,7 +43,7 @@ void SerialController::FlushPorts()
int maxIndex = 0; int maxIndex = 0;
qDebug() << "List of ports:"; qDebug() << "List of ports:";
foreach (QextPortInfo info, mPorts) { foreach (QextPortInfo info, mPorts) {
qDebug() << "port name:" << info.portName; qDebug() << "port name:" << QString().fromUtf8(info.portName.toUtf8());
qDebug() << "friendly name:" << info.friendName; qDebug() << "friendly name:" << info.friendName;
qDebug() << "physical name:" << info.physName; qDebug() << "physical name:" << info.physName;
qDebug() << "enumerator name:" << info.enumName; qDebug() << "enumerator name:" << info.enumName;

View File

@ -13,6 +13,7 @@
#define NULLPOINTER -1 #define NULLPOINTER -1
/* /*
*
data -> controler -> proto -> listener data -> controler -> proto -> listener
*/ */
using namespace std; using namespace std;

View File

@ -0,0 +1,6 @@
#include "sharedata.h"
ShareData::ShareData(QObject *parent) : QObject(parent)
{
}

20
protoDebuger/sharedata.h Normal file
View File

@ -0,0 +1,20 @@
#ifndef SHAREDATA_H
#define SHAREDATA_H
#include <QObject>
#include <QDebug>
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