画了一个简单的qml界面用于测试指令
This commit is contained in:
+111
-39
@@ -1,98 +1,170 @@
|
||||
import QtQuick 2.6
|
||||
//import QtQuick.Controls 2.2
|
||||
import QtQuick.Controls 2.5
|
||||
|
||||
//导入指令模块,这样就能发指令了
|
||||
//import Protocol.MavLinkNode 1.0
|
||||
|
||||
|
||||
Rectangle {
|
||||
|
||||
id:root
|
||||
|
||||
visible: true
|
||||
x:0
|
||||
y:0
|
||||
border.width: 1
|
||||
border.color: "blue"
|
||||
color: "white"
|
||||
|
||||
signal btnclicked_int(real param1, real param2, real param3, real param4, int x, int y, real z)
|
||||
signal btnclicked_long(real param1, real param2, real param3, real param4, real param5, real param6, real param7)
|
||||
|
||||
|
||||
Rectangle {
|
||||
id:loadqml
|
||||
x:20
|
||||
id:armbtn
|
||||
x:10
|
||||
y:20
|
||||
width: 100
|
||||
radius: 5
|
||||
width: 80
|
||||
height: 40
|
||||
border.width:1
|
||||
color: "lightgreen"
|
||||
|
||||
color: "blue"
|
||||
Text{
|
||||
anchors.centerIn: parent
|
||||
text: qsTr("ARM")
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
hoverEnabled: true //默认是false
|
||||
x:0
|
||||
y:0
|
||||
anchors.fill: parent
|
||||
|
||||
onEntered: {
|
||||
loadqml.color = "yellow"
|
||||
console.log("Entered")
|
||||
parent.color = "yellow"
|
||||
}
|
||||
onExited:{
|
||||
loadqml.color = "blue"
|
||||
console.log("Exited")
|
||||
parent.color = "lightgreen"
|
||||
}
|
||||
|
||||
onPressed: {
|
||||
parent.width = parent.width - 4
|
||||
parent.height = parent.height - 2
|
||||
parent.x = parent.x + 2
|
||||
parent.y = parent.y + 1
|
||||
parent.border.width = 2
|
||||
|
||||
}
|
||||
onReleased:{
|
||||
parent.width = parent.width + 4
|
||||
parent.height = parent.height + 2
|
||||
parent.x = parent.x - 2
|
||||
parent.y = parent.y - 1
|
||||
parent.border.width = 1
|
||||
}
|
||||
|
||||
onClicked: {
|
||||
console.log("clicked")
|
||||
btnclicked_int(0,0,0,0,0,0,0)
|
||||
}
|
||||
onClicked: console.log("Clicked")
|
||||
onReleased: console.log("Released")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: loadbtn
|
||||
id: takeoffbtn
|
||||
|
||||
x:20
|
||||
y:80
|
||||
width: 100
|
||||
height: 20
|
||||
|
||||
color: "blue"
|
||||
x:100
|
||||
y:20
|
||||
radius: 5
|
||||
width: 80
|
||||
height: 40
|
||||
border.width:1
|
||||
color: "lightgreen"
|
||||
|
||||
Text{
|
||||
text: qsTr("Load")
|
||||
anchors.centerIn: parent
|
||||
text: qsTr("TakeOff")
|
||||
}
|
||||
|
||||
MouseArea{
|
||||
hoverEnabled: true //默认是false
|
||||
anchors.fill: parent
|
||||
onClicked: console.log("loadbtn")
|
||||
|
||||
onEntered: {
|
||||
loadbtn.color = "yellow"
|
||||
console.log("Entered")
|
||||
parent.color = "yellow"
|
||||
}
|
||||
onExited:{
|
||||
loadbtn.color = "blue"
|
||||
console.log("Exited")
|
||||
parent.color = "lightgreen"
|
||||
}
|
||||
onPressed: {
|
||||
parent.width = parent.width - 4
|
||||
parent.height = parent.height - 2
|
||||
parent.x = parent.x + 2
|
||||
parent.y = parent.y + 1
|
||||
parent.border.width = 2
|
||||
|
||||
}
|
||||
onReleased:{
|
||||
parent.width = parent.width + 4
|
||||
parent.height = parent.height + 2
|
||||
parent.x = parent.x - 2
|
||||
parent.y = parent.y - 1
|
||||
parent.border.width = 1
|
||||
}
|
||||
|
||||
onClicked: {
|
||||
console.log("clicked")
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: resetbtn
|
||||
id: killbtn
|
||||
|
||||
x:20
|
||||
y:150
|
||||
width: 100
|
||||
height: 20
|
||||
x:190
|
||||
y:20
|
||||
radius: 5
|
||||
width: 80
|
||||
height: 40
|
||||
border.width:1
|
||||
color: "darkorange"
|
||||
|
||||
color: "blue"
|
||||
|
||||
Text{
|
||||
text: qsTr("Reset")
|
||||
anchors.centerIn: parent
|
||||
text: qsTr("Kill")
|
||||
}
|
||||
|
||||
MouseArea{
|
||||
|
||||
hoverEnabled: true //默认是false
|
||||
anchors.fill: parent
|
||||
onClicked: console.log("resetbtn")
|
||||
|
||||
onEntered: {
|
||||
resetbtn.color = "yellow"
|
||||
console.log("Entered")
|
||||
parent.color = "yellow"
|
||||
}
|
||||
onExited:{
|
||||
resetbtn.color = "blue"
|
||||
console.log("Exited")
|
||||
parent.color = "darkorange"
|
||||
}
|
||||
onPressed: {
|
||||
parent.color = "red"
|
||||
parent.width = parent.width - 4
|
||||
parent.height = parent.height - 2
|
||||
parent.x = parent.x + 2
|
||||
parent.y = parent.y + 1
|
||||
parent.border.width = 2
|
||||
|
||||
}
|
||||
onReleased:{
|
||||
parent.width = parent.width + 4
|
||||
parent.height = parent.height + 2
|
||||
parent.x = parent.x - 2
|
||||
parent.y = parent.y - 1
|
||||
parent.border.width = 1
|
||||
}
|
||||
|
||||
onClicked: {
|
||||
console.log("clicked")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
#include <QDebug>
|
||||
#include <QTextCodec>
|
||||
|
||||
#include <QQmlEngine>
|
||||
|
||||
//#include <windows.h>
|
||||
//#include <winver.h>
|
||||
//#pragma comment(lib, "Version")
|
||||
@@ -108,6 +110,13 @@ int main(int argc, char *argv[])
|
||||
|
||||
a.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
w.show();
|
||||
|
||||
return a.exec();
|
||||
|
||||
+17
-24
@@ -1,21 +1,15 @@
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include "QPushButton"
|
||||
#include "QAction"
|
||||
|
||||
|
||||
#include "QHBoxLayout"
|
||||
|
||||
|
||||
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
{
|
||||
|
||||
|
||||
//this->setAttribute(Qt::AA_NativeWindows);
|
||||
|
||||
//qmlRegisterType<DLink>("Protocol.DLink", 1, 0, "DLink");
|
||||
|
||||
//ui initial
|
||||
linkui = new LinkUI(this);
|
||||
@@ -45,7 +39,6 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
|
||||
|
||||
map = new mapcontrol::OPMapWidget(this);
|
||||
|
||||
map->SetShowHome(false);
|
||||
map->SetShowCompass(false);
|
||||
map->SetUseOpenGL(true);
|
||||
@@ -61,6 +54,9 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
QIcon icon;
|
||||
|
||||
nav = new QNavigationWidget(this);
|
||||
|
||||
nav->setAttribute(Qt::WA_AlwaysStackOnTop);
|
||||
|
||||
nav->setGeometry(0,0,50,this->height());
|
||||
nav->setRowHeight(50);
|
||||
nav->addItem(tr("Flight"),icon);
|
||||
@@ -71,6 +67,8 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
nav->addItem(tr("Data"),icon);//all data
|
||||
nav->addItem(tr("Tools"),icon);//soft setting help about
|
||||
|
||||
|
||||
|
||||
connect(nav,SIGNAL(ItemChanged(int)),
|
||||
this,SLOT(onTabIndexChanged(int)));
|
||||
|
||||
@@ -143,14 +141,19 @@ void MainWindow::resizeEvent(QResizeEvent *event)
|
||||
this->width()- copk->width() - nav->width(),
|
||||
this->height());
|
||||
|
||||
/*
|
||||
map->setGeometry(0,
|
||||
0,
|
||||
this->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());
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -162,11 +165,9 @@ void MainWindow::keyPressEvent(QKeyEvent *event) //键盘按下事件
|
||||
case Qt::Key_A:
|
||||
break;
|
||||
case Qt::Key_D:
|
||||
|
||||
if(event->modifiers() == Qt::AltModifier)
|
||||
{
|
||||
qInfo() << "alt + D";
|
||||
dlink->mavlinknode->Mission->ReadCmd(1,1);
|
||||
}
|
||||
break;
|
||||
case Qt::Key_U :
|
||||
@@ -174,8 +175,6 @@ void MainWindow::keyPressEvent(QKeyEvent *event) //键盘按下事件
|
||||
if(event->modifiers() == Qt::AltModifier)
|
||||
{
|
||||
qInfo() << "atl + U";
|
||||
//dlink->Mavlink_msg_mission_count(map->WPTotal());
|
||||
//qDebug() << map->WPTotal();
|
||||
}
|
||||
}break;
|
||||
case Qt::Key_P :
|
||||
@@ -183,8 +182,6 @@ void MainWindow::keyPressEvent(QKeyEvent *event) //键盘按下事件
|
||||
if(event->modifiers() == Qt::AltModifier)
|
||||
{//下载参数
|
||||
qInfo() << "atl + P";
|
||||
dlink->mavlinknode->Parameter->ReadCmd(1,1,1);
|
||||
|
||||
}
|
||||
}break;
|
||||
case Qt::Key_O :
|
||||
@@ -192,8 +189,6 @@ void MainWindow::keyPressEvent(QKeyEvent *event) //键盘按下事件
|
||||
if(event->modifiers() == Qt::AltModifier)
|
||||
{//上传参数
|
||||
qInfo() << "atl + O";
|
||||
//dlink->Mavlink_msg_mission_count(map->WPTotal());
|
||||
|
||||
}
|
||||
}break;
|
||||
case Qt::Key_S:
|
||||
@@ -211,8 +206,6 @@ void MainWindow::keyPressEvent(QKeyEvent *event) //键盘按下事件
|
||||
case Qt::Key_Space :
|
||||
{
|
||||
internals::PointLatLng LatLng;
|
||||
//LatLng.SetLat(dlink->v*1e-7);
|
||||
//LatLng.SetLng(dlink->vehicle.gps_raw_int.lon*1e-7);
|
||||
map->SetCurrentPosition(LatLng);
|
||||
}
|
||||
break;
|
||||
@@ -354,7 +347,7 @@ void MainWindow::dlink_triggered()
|
||||
disconnectdialog dlg(this);
|
||||
|
||||
dlg.setWindowTitle(tr("SerialPort"));
|
||||
dlg.setWindowIcon(QIcon(":/images/LinkUI/SerialPort.ico"));
|
||||
dlg.setWindowIcon(QIcon("qrc:/images/LinkUI/SerialPort.ico"));
|
||||
|
||||
int ret = dlg.exec();
|
||||
if (QDialog::Accepted == ret)
|
||||
@@ -367,7 +360,7 @@ void MainWindow::dlink_triggered()
|
||||
ConnectDialog dlg(this);
|
||||
|
||||
dlg.setWindowTitle(tr("SerialPort"));
|
||||
dlg.setWindowIcon(QIcon(":/images/LinkUI/SerialPort.ico"));
|
||||
dlg.setWindowIcon(QIcon("qrc:/images/LinkUI/SerialPort.ico"));
|
||||
|
||||
dlg.baudrate = 115200;
|
||||
dlg.parity = QSerialPort::NoParity;
|
||||
|
||||
Reference in New Issue
Block a user