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\\extserial\\src\\qextserialport.cmake)
|
||||
|
||||
QT5_WRAP_CPP(MOC ${SOURCES} ) # moc预编译代码
|
||||
QT5_WRAP_CPP(MOCHEADER ${HEADERS} ) # moc预编译代码
|
||||
|
@ -86,6 +85,7 @@ target_compile_definitions(protoDebuger
|
|||
PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)
|
||||
|
||||
find_package( Qt5SerialPort)
|
||||
find_package( Qt5QuickWidgets)
|
||||
|
||||
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
|
||||
Layout.columnSpan: 2
|
||||
Layout.preferredHeight: 33
|
||||
Layout.preferredWidth: 233
|
||||
Layout.preferredWidth: 50
|
||||
selectionColor: "#f0f0f1"
|
||||
cursorVisible: true
|
||||
font.pixelSize: 20
|
||||
}
|
||||
|
||||
RadioButton {
|
||||
id: radioButton
|
||||
Layout.leftMargin: 20
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <QByteArray>
|
||||
#include <QtWidgets/QApplication>
|
||||
#include <QQuickView>
|
||||
#include <QtQuickWidgets/QQuickWidget>
|
||||
#include <QQmlComponent>
|
||||
#include <QQmlContext>
|
||||
#include <QtSerialPort/QSerialPort>
|
||||
|
@ -16,24 +17,27 @@
|
|||
|
||||
ShareData gGlobal;
|
||||
|
||||
void RegisterQmlType(){
|
||||
qmlRegisterSingletonInstance<ShareData>("ShareData", 1, 0, "DataWrap",&gGlobal);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
QGuiApplication app(argc, argv);
|
||||
SerialController *pSerial = new SerialController();
|
||||
QQuickView view;
|
||||
QApplication app(argc, argv);
|
||||
|
||||
view.setResizeMode(QQuickView::SizeRootObjectToView);
|
||||
view.setSource(QUrl("qrc:/main.qml"));
|
||||
view.setTitle ("多用途通信协议调试器,基于lua");
|
||||
view.rootContext()->setContextProperty("DataWrap",&gGlobal);
|
||||
// QQuickView view;
|
||||
// view.setResizeMode(QQuickView::SizeRootObjectToView);
|
||||
// view.setSource(QUrl("qrc:/main.qml"));
|
||||
// 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();
|
||||
}
|
||||
|
|
|
@ -5,12 +5,12 @@ import QtQuick.Controls 2.14
|
|||
import QtQuick.Layouts 1.12
|
||||
|
||||
Rectangle {
|
||||
objectName: "main"
|
||||
id: root
|
||||
width: 800
|
||||
height: 600
|
||||
width: 1440
|
||||
height: 900
|
||||
visible: true
|
||||
|
||||
|
||||
Flow{
|
||||
anchors.fill: parent
|
||||
width: parent.width
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
#include <QtSerialPort/QSerialPortInfo>
|
||||
#include <QFile>
|
||||
#include <QThread>
|
||||
#include <QQuickItem>
|
||||
#include <QQmlContext>
|
||||
|
||||
ShareData::ShareData(QObject *parent) : QObject(parent),
|
||||
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;
|
||||
const auto infos = QSerialPortInfo::availablePorts();
|
||||
for (const QSerialPortInfo &info : infos) {
|
||||
comList<<info.portName();
|
||||
}
|
||||
|
||||
|
||||
// 设置qml基本属性
|
||||
this->m_qml_view_ = view;
|
||||
QObject *qmlObject = view->findChild<QObject*>("SerialSelect",
|
||||
QObject *qmlObject = view->rootObject()->findChild<QObject*>("SerialSelect",
|
||||
Qt::FindChildOption::FindChildrenRecursively);
|
||||
if(nullptr != qmlObject)
|
||||
qmlObject->setProperty("comlist",comList);
|
||||
m_qml_protodebug_ = view->findChild<QObject*>("ProtoDebug",
|
||||
m_qml_protodebug_ = view->rootObject()->findChild<QObject*>("ProtoDebug",
|
||||
Qt::FindChildOption::FindChildrenRecursively);
|
||||
|
||||
if(nullptr != m_qml_protodebug_)
|
||||
m_qml_protodebug_->setProperty("lua_script_text",m_lua_string);
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <QObject>
|
||||
#include <QDebug>
|
||||
#include "lua_wraper.h"
|
||||
#include <QQuickView>
|
||||
#include <QtQuickWidgets/QQuickWidget>
|
||||
|
||||
class ShareData;
|
||||
|
||||
|
@ -20,7 +20,7 @@ class ShareData : public QObject ,SerialController::SerialListener
|
|||
Q_PROPERTY(QString _txt READ rtxt WRITE settxt NOTIFY txtchanged)
|
||||
public:
|
||||
explicit ShareData(QObject *parent = nullptr);
|
||||
int SetQuickView(QQuickView *);
|
||||
int SetQuickView(QQuickWidget *);
|
||||
QString rtxt() const{
|
||||
return _txt;
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ private:
|
|||
QObject *m_root_obj_;
|
||||
bool m_luavm_status_;
|
||||
QString m_lua_string;
|
||||
QQuickView *m_qml_view_;
|
||||
QQuickWidget *m_qml_view_;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue