no message
parent
6f2e4cec39
commit
70c898e74a
|
@ -55,7 +55,6 @@ set (UIS
|
||||||
)
|
)
|
||||||
|
|
||||||
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预编译代码
|
||||||
|
@ -86,6 +85,7 @@ target_compile_definitions(protoDebuger
|
||||||
PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)
|
PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)
|
||||||
|
|
||||||
find_package( Qt5SerialPort)
|
find_package( Qt5SerialPort)
|
||||||
|
find_package( Qt5QuickWidgets)
|
||||||
|
|
||||||
target_link_libraries(protoDebuger
|
target_link_libraries(protoDebuger
|
||||||
PRIVATE Qt5::Core Qt5::Quick Qt5::Widgets Qt5::SerialPort Qt5::Network) # 指定引入的QT功能,和qmake .pro 文件中的QT+= XXX类似
|
PRIVATE Qt5::Core Qt5::Quick Qt5::Widgets Qt5::SerialPort Qt5::Network Qt5::QuickWidgets)
|
||||||
|
|
|
@ -56,11 +56,12 @@ Item {
|
||||||
font.bold: true
|
font.bold: true
|
||||||
Layout.columnSpan: 2
|
Layout.columnSpan: 2
|
||||||
Layout.preferredHeight: 33
|
Layout.preferredHeight: 33
|
||||||
Layout.preferredWidth: 233
|
Layout.preferredWidth: 50
|
||||||
selectionColor: "#f0f0f1"
|
selectionColor: "#f0f0f1"
|
||||||
cursorVisible: true
|
cursorVisible: true
|
||||||
font.pixelSize: 20
|
font.pixelSize: 20
|
||||||
}
|
}
|
||||||
|
|
||||||
RadioButton {
|
RadioButton {
|
||||||
id: radioButton
|
id: radioButton
|
||||||
Layout.leftMargin: 20
|
Layout.leftMargin: 20
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <QtWidgets/QApplication>
|
#include <QtWidgets/QApplication>
|
||||||
#include <QQuickView>
|
#include <QQuickView>
|
||||||
|
#include <QtQuickWidgets/QQuickWidget>
|
||||||
#include <QQmlComponent>
|
#include <QQmlComponent>
|
||||||
#include <QQmlContext>
|
#include <QQmlContext>
|
||||||
#include <QtSerialPort/QSerialPort>
|
#include <QtSerialPort/QSerialPort>
|
||||||
|
@ -16,24 +17,27 @@
|
||||||
|
|
||||||
ShareData gGlobal;
|
ShareData gGlobal;
|
||||||
|
|
||||||
void RegisterQmlType(){
|
|
||||||
qmlRegisterSingletonInstance<ShareData>("ShareData", 1, 0, "DataWrap",&gGlobal);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||||
QGuiApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
SerialController *pSerial = new SerialController();
|
|
||||||
QQuickView view;
|
|
||||||
|
|
||||||
view.setResizeMode(QQuickView::SizeRootObjectToView);
|
// QQuickView view;
|
||||||
view.setSource(QUrl("qrc:/main.qml"));
|
// view.setResizeMode(QQuickView::SizeRootObjectToView);
|
||||||
view.setTitle ("多用途通信协议调试器,基于lua");
|
// view.setSource(QUrl("qrc:/main.qml"));
|
||||||
view.rootContext()->setContextProperty("DataWrap",&gGlobal);
|
// view.setTitle ("多用途通信协议调试器,基于lua");
|
||||||
|
// view.rootContext()->setContextProperty("DataWrap",&gGlobal);
|
||||||
|
// view.show();
|
||||||
|
|
||||||
|
QQuickWidget *m_quickWidget=new QQuickWidget();
|
||||||
|
QUrl source("qrc:/main.qml");
|
||||||
|
m_quickWidget->setResizeMode(QQuickWidget::SizeRootObjectToView );
|
||||||
|
m_quickWidget->setSource(source);
|
||||||
|
m_quickWidget->rootContext()->setContextProperty("DataWrap",&gGlobal);
|
||||||
|
m_quickWidget->show();
|
||||||
|
gGlobal.SetQuickView(m_quickWidget);
|
||||||
|
|
||||||
view.show();
|
|
||||||
gGlobal.SetQuickView(&view);
|
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,12 +5,12 @@ import QtQuick.Controls 2.14
|
||||||
import QtQuick.Layouts 1.12
|
import QtQuick.Layouts 1.12
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
objectName: "main"
|
||||||
id: root
|
id: root
|
||||||
width: 800
|
width: 1440
|
||||||
height: 600
|
height: 900
|
||||||
visible: true
|
visible: true
|
||||||
|
|
||||||
|
|
||||||
Flow{
|
Flow{
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
#include <QtSerialPort/QSerialPortInfo>
|
#include <QtSerialPort/QSerialPortInfo>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
#include <QQuickItem>
|
||||||
|
#include <QQmlContext>
|
||||||
|
|
||||||
ShareData::ShareData(QObject *parent) : QObject(parent),
|
ShareData::ShareData(QObject *parent) : QObject(parent),
|
||||||
m_qml_view_(nullptr),
|
m_qml_view_(nullptr),
|
||||||
|
@ -24,22 +26,22 @@ ShareData::ShareData(QObject *parent) : QObject(parent),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int ShareData::SetQuickView(QQuickView *view)
|
int ShareData::SetQuickView(QQuickWidget *view)
|
||||||
{
|
{
|
||||||
QStringList comList;
|
QStringList comList;
|
||||||
const auto infos = QSerialPortInfo::availablePorts();
|
const auto infos = QSerialPortInfo::availablePorts();
|
||||||
for (const QSerialPortInfo &info : infos) {
|
for (const QSerialPortInfo &info : infos) {
|
||||||
comList<<info.portName();
|
comList<<info.portName();
|
||||||
}
|
}
|
||||||
|
// 设置qml基本属性
|
||||||
|
|
||||||
this->m_qml_view_ = view;
|
this->m_qml_view_ = view;
|
||||||
QObject *qmlObject = view->findChild<QObject*>("SerialSelect",
|
QObject *qmlObject = view->rootObject()->findChild<QObject*>("SerialSelect",
|
||||||
Qt::FindChildOption::FindChildrenRecursively);
|
Qt::FindChildOption::FindChildrenRecursively);
|
||||||
if(nullptr != qmlObject)
|
if(nullptr != qmlObject)
|
||||||
qmlObject->setProperty("comlist",comList);
|
qmlObject->setProperty("comlist",comList);
|
||||||
m_qml_protodebug_ = view->findChild<QObject*>("ProtoDebug",
|
m_qml_protodebug_ = view->rootObject()->findChild<QObject*>("ProtoDebug",
|
||||||
Qt::FindChildOption::FindChildrenRecursively);
|
Qt::FindChildOption::FindChildrenRecursively);
|
||||||
|
|
||||||
if(nullptr != m_qml_protodebug_)
|
if(nullptr != m_qml_protodebug_)
|
||||||
m_qml_protodebug_->setProperty("lua_script_text",m_lua_string);
|
m_qml_protodebug_->setProperty("lua_script_text",m_lua_string);
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include "lua_wraper.h"
|
#include "lua_wraper.h"
|
||||||
#include <QQuickView>
|
#include <QtQuickWidgets/QQuickWidget>
|
||||||
|
|
||||||
class ShareData;
|
class ShareData;
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ class ShareData : public QObject ,SerialController::SerialListener
|
||||||
Q_PROPERTY(QString _txt READ rtxt WRITE settxt NOTIFY txtchanged)
|
Q_PROPERTY(QString _txt READ rtxt WRITE settxt NOTIFY txtchanged)
|
||||||
public:
|
public:
|
||||||
explicit ShareData(QObject *parent = nullptr);
|
explicit ShareData(QObject *parent = nullptr);
|
||||||
int SetQuickView(QQuickView *);
|
int SetQuickView(QQuickWidget *);
|
||||||
QString rtxt() const{
|
QString rtxt() const{
|
||||||
return _txt;
|
return _txt;
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ private:
|
||||||
QObject *m_root_obj_;
|
QObject *m_root_obj_;
|
||||||
bool m_luavm_status_;
|
bool m_luavm_status_;
|
||||||
QString m_lua_string;
|
QString m_lua_string;
|
||||||
QQuickView *m_qml_view_;
|
QQuickWidget *m_qml_view_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue