添加了一个qml窗口,这个窗口无法和当前界面兼容导致界面使用的其他小部件布局无法和以前一样,map无法全部铺满
This commit is contained in:
+9
-1
@@ -6,6 +6,10 @@
|
||||
|
||||
QT += core gui network
|
||||
QT += serialport
|
||||
QT += quickwidgets
|
||||
QT += quick
|
||||
QT += qml
|
||||
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
@@ -101,7 +105,8 @@ win32|win64 {
|
||||
src_dir ~= s,/,\\,g
|
||||
dst_dir ~= s,/,\\,g
|
||||
|
||||
system(xcopy $$src_dir $$dst_dir /y /e)
|
||||
#要发布时要打开,复制必要的库文件
|
||||
#system(xcopy $$src_dir $$dst_dir /y /e)
|
||||
}
|
||||
|
||||
|
||||
@@ -111,3 +116,6 @@ DEFINES += BUILD_WITH_HDMI
|
||||
|
||||
TRANSLATIONS = qt_zh.ts qt_en.ts
|
||||
|
||||
RESOURCES += \
|
||||
res.qrc
|
||||
|
||||
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
import QtQuick 2.6
|
||||
//import QtQuick.Controls 2.2
|
||||
|
||||
Rectangle {
|
||||
visible: true
|
||||
x:0
|
||||
y:0
|
||||
color: "white"
|
||||
|
||||
|
||||
Rectangle {
|
||||
id:loadqml
|
||||
x:20
|
||||
y:20
|
||||
width: 100
|
||||
height: 40
|
||||
|
||||
color: "blue"
|
||||
|
||||
MouseArea {
|
||||
hoverEnabled: true //默认是false
|
||||
x:0
|
||||
y:0
|
||||
anchors.fill: parent
|
||||
|
||||
onEntered: {
|
||||
loadqml.color = "yellow"
|
||||
console.log("Entered")
|
||||
}
|
||||
onExited:{
|
||||
loadqml.color = "blue"
|
||||
console.log("Exited")
|
||||
}
|
||||
onClicked: console.log("Clicked")
|
||||
onReleased: console.log("Released")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: loadbtn
|
||||
|
||||
x:20
|
||||
y:80
|
||||
width: 100
|
||||
height: 20
|
||||
|
||||
color: "blue"
|
||||
|
||||
Text{
|
||||
text: qsTr("Load")
|
||||
}
|
||||
|
||||
MouseArea{
|
||||
anchors.fill: parent
|
||||
onClicked: console.log("loadbtn")
|
||||
|
||||
onEntered: {
|
||||
loadbtn.color = "yellow"
|
||||
console.log("Entered")
|
||||
}
|
||||
onExited:{
|
||||
loadbtn.color = "blue"
|
||||
console.log("Exited")
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: resetbtn
|
||||
|
||||
x:20
|
||||
y:150
|
||||
width: 100
|
||||
height: 20
|
||||
|
||||
color: "blue"
|
||||
|
||||
Text{
|
||||
text: qsTr("Reset")
|
||||
}
|
||||
|
||||
MouseArea{
|
||||
|
||||
anchors.fill: parent
|
||||
onClicked: console.log("resetbtn")
|
||||
|
||||
onEntered: {
|
||||
resetbtn.color = "yellow"
|
||||
console.log("Entered")
|
||||
}
|
||||
onExited:{
|
||||
resetbtn.color = "blue"
|
||||
console.log("Exited")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -70,6 +70,7 @@ void CheckDirs(const QString &path, const QStringList &dirs) {
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
|
||||
MainWindow w;
|
||||
|
||||
QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF8"));
|
||||
@@ -105,6 +106,8 @@ int main(int argc, char *argv[])
|
||||
w.resize(GetDesktopSize());
|
||||
|
||||
|
||||
a.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
|
||||
|
||||
w.show();
|
||||
|
||||
return a.exec();
|
||||
|
||||
+30
-10
@@ -8,9 +8,15 @@
|
||||
|
||||
|
||||
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
{
|
||||
|
||||
|
||||
//this->setAttribute(Qt::AA_NativeWindows);
|
||||
|
||||
|
||||
//ui initial
|
||||
linkui = new LinkUI(this);
|
||||
linkui->hide();
|
||||
@@ -33,15 +39,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
setting->hide();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
dlink = new DLink();
|
||||
|
||||
/*
|
||||
connect(dlink->mavlinknode,&MavLinkNode::state_updated,
|
||||
this,&MainWindow::updateUI);
|
||||
*/
|
||||
connect(dlink->mavlinknode,SIGNAL(state_updated()),
|
||||
this,SLOT(updateUI()));
|
||||
|
||||
@@ -76,6 +74,22 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
connect(nav,SIGNAL(ItemChanged(int)),
|
||||
this,SLOT(onTabIndexChanged(int)));
|
||||
|
||||
|
||||
|
||||
|
||||
quick = new QQuickWidget(this);
|
||||
|
||||
quick->setFocus();
|
||||
quick->setResizeMode(QQuickWidget::SizeRootObjectToView);
|
||||
quick->setAttribute(Qt::WA_AlwaysStackOnTop);
|
||||
|
||||
QUrl source("qrc:/App/qml/base.qml");
|
||||
quick->setSource(source);
|
||||
|
||||
quick->setGeometry(this->width() - copk->width(),copk->height(),300,this->height() - copk->height());
|
||||
quick->show();
|
||||
|
||||
|
||||
copk = new Cockpit(this);
|
||||
copk->setGeometry(this->width() - copk->width(),0,300,340);
|
||||
|
||||
@@ -124,15 +138,19 @@ void MainWindow::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
|
||||
map->setGeometry(0,
|
||||
map->setGeometry(nav->width(),
|
||||
0,
|
||||
this->width(),
|
||||
this->width()- copk->width() - nav->width(),
|
||||
this->height());
|
||||
|
||||
nav->setGeometry(0,0,nav->width(),this->height());
|
||||
|
||||
|
||||
|
||||
copk->setGeometry(this->width() - copk->width(),0,copk->width(),copk->height());
|
||||
|
||||
quick->setGeometry(this->width() - quick->width(),copk->height(),quick->width(),this->height() - copk->height());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -288,11 +306,13 @@ void MainWindow::onTabIndexChanged(const int &index)//界面选择管理
|
||||
{
|
||||
map->show();
|
||||
copk->show();
|
||||
quick->show();
|
||||
}
|
||||
else
|
||||
{
|
||||
map->hide();
|
||||
copk->hide();
|
||||
quick->hide();
|
||||
}
|
||||
|
||||
|
||||
|
||||
+11
-2
@@ -31,6 +31,15 @@
|
||||
#include "Help/Help.h"
|
||||
#include "Setting/Setting.h"
|
||||
|
||||
|
||||
|
||||
//cmd ui
|
||||
#include "QQuickWidget"
|
||||
#include "QQuickView"
|
||||
|
||||
|
||||
|
||||
|
||||
#pragma execution_character_set("utf-8")
|
||||
|
||||
|
||||
@@ -41,7 +50,7 @@ class MainWindow : public QMainWindow
|
||||
|
||||
|
||||
public:
|
||||
MainWindow(QWidget *parent = 0);
|
||||
MainWindow(QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
|
||||
|
||||
@@ -88,7 +97,7 @@ protected:
|
||||
Setting *setting = nullptr;
|
||||
|
||||
|
||||
|
||||
QQuickWidget *quick = nullptr;
|
||||
|
||||
QTimer *updateTimer;
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<RCC>
|
||||
<qresource prefix="/App/qml">
|
||||
<file>base.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
@@ -4,11 +4,7 @@ TEMPLATE = subdirs
|
||||
|
||||
CONFIG += ordered
|
||||
|
||||
|
||||
|
||||
SUBDIRS += MavLinkNode
|
||||
#SUBDIRS += MAVLinkInspector
|
||||
|
||||
|
||||
SUBDIRS += SerialPortDialog
|
||||
SUBDIRS += ClientLinkDialog
|
||||
|
||||
@@ -78,7 +78,6 @@ void commandprocess::process()//线程函数
|
||||
thread = nullptr;
|
||||
}
|
||||
|
||||
|
||||
void commandprocess::SendMessage(mavlink_message_t msg)
|
||||
{
|
||||
uint8_t buff[256+20];
|
||||
@@ -89,13 +88,25 @@ void commandprocess::SendMessage(mavlink_message_t msg)
|
||||
//这个函数类似中断,专门处理接收到的状态
|
||||
void commandprocess::Parse(mavlink_message_t msg)
|
||||
{
|
||||
mavlink_command_int_t command_int;
|
||||
mavlink_command_long_t command_long;
|
||||
mavlink_command_ack_t command_ack;
|
||||
|
||||
switch (msg.msgid) {
|
||||
case MAVLINK_MSG_ID_COMMAND_INT:
|
||||
case MAVLINK_MSG_ID_COMMAND_INT://几乎不可能收到
|
||||
mavlink_msg_command_int_decode(&msg,&command_int);
|
||||
case MAVLINK_MSG_ID_COMMAND_LONG:
|
||||
break;
|
||||
case MAVLINK_MSG_ID_COMMAND_LONG://几乎不可能收到
|
||||
mavlink_msg_command_long_decode(&msg,&command_long);
|
||||
break;
|
||||
case MAVLINK_MSG_ID_COMMAND_ACK:
|
||||
mavlink_msg_command_ack_decode(&msg,&command_ack);
|
||||
|
||||
if(command_ack.result == MAV_RESULT_ACCEPTED)
|
||||
{
|
||||
status.transmit.isWaitingforACK = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,8 +114,8 @@ void commandprocess::Parse(mavlink_message_t msg)
|
||||
void commandprocess::ReadStateMachine(void)//没有读指令这个说法
|
||||
{
|
||||
static uint8_t step = 0;
|
||||
static uint8_t timeout_count = 0;
|
||||
static uint32_t time = 0;
|
||||
//static uint8_t timeout_count = 0;
|
||||
static int time = 0;
|
||||
|
||||
|
||||
if(step == 0)
|
||||
@@ -125,11 +136,10 @@ void commandprocess::WriteStateMachine(void)
|
||||
{
|
||||
static uint8_t step = 0;
|
||||
static uint8_t timeout_count = 0;
|
||||
static uint32_t time = 0;
|
||||
static int time = 0;
|
||||
|
||||
if(step == 0)
|
||||
{
|
||||
|
||||
status.transmit.isWaitingforACK = true;
|
||||
|
||||
//set("id",0,1);//发送一个指令
|
||||
@@ -168,7 +178,6 @@ void commandprocess::WriteStateMachine(void)
|
||||
|
||||
|
||||
/*all msg
|
||||
|
||||
MAVLINK_MSG_ID_COMMAND_INT
|
||||
MAVLINK_MSG_ID_COMMAND_LONG
|
||||
MAVLINK_MSG_ID_COMMAND_ACK
|
||||
@@ -251,9 +260,21 @@ void commandprocess::_long(float param1,
|
||||
**/
|
||||
|
||||
|
||||
void commandprocess::ack()//地面站几乎不可能放这个函数
|
||||
void commandprocess::ack(uint16_t command,uint8_t result,uint8_t progress,int32_t result_param2)//地面站几乎不可能放这个函数
|
||||
{
|
||||
static mavlink_message_t msg;
|
||||
static mavlink_command_ack_t command_ack;
|
||||
|
||||
command_ack.target_system = sysid;
|
||||
command_ack.target_component = compid;
|
||||
|
||||
command_ack.command = command;
|
||||
command_ack.result = result;
|
||||
command_ack.progress = progress;
|
||||
command_ack.result_param2 = result_param2;
|
||||
|
||||
mavlink_msg_command_ack_encode(2,MAV_COMP_ID_MISSIONPLANNER, &msg,&command_ack);
|
||||
SendMessage(msg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ private slots:
|
||||
float param7,
|
||||
uint16_t command,
|
||||
uint8_t confirmation);
|
||||
void ack();
|
||||
void ack(uint16_t command,uint8_t result,uint8_t progress,int32_t result_param2);
|
||||
|
||||
|
||||
signals:
|
||||
@@ -116,9 +116,7 @@ private:
|
||||
uint8_t sysid;
|
||||
uint8_t compid;
|
||||
|
||||
mavlink_command_int_t command_int;
|
||||
mavlink_command_long_t command_long;
|
||||
mavlink_command_ack_t command_ack;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user