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
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}) # rcccpp
QT5_WRAP_UI(UIC ${UIS}) # uicui_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

View File

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

View File

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

View File

@ -1,12 +1,20 @@
#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"));
@ -17,5 +25,14 @@ int main(int argc, char *argv[])
}, 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();
}

View File

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

View File

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

View File

@ -13,6 +13,7 @@
#define NULLPOINTER -1
/*
*
data -> controler -> proto -> listener
*/
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