添加伺服系统

This commit is contained in:
hm
2020-10-06 17:11:59 +08:00
parent 16579855c0
commit 6da5821dcb
12 changed files with 439 additions and 10 deletions
+52 -5
View File
@@ -7,6 +7,15 @@ PowerSystem::PowerSystem(QWidget *parent) :
{ {
ui->setupUi(this); ui->setupUi(this);
par = parent;
//setContextMenuPolicy(Qt::ActionsContextMenu);
//ui->checkBox->setCheckable(true); //ui->checkBox->setCheckable(true);
//ui->checkBox->setChecked(true); //ui->checkBox->setChecked(true);
//ui->checkBox->setCheckable(false); //ui->checkBox->setCheckable(false);
@@ -61,11 +70,49 @@ PowerSystem::~PowerSystem()
} }
void PowerSystem::mousePressEvent(QMouseEvent *event)
{
if(event->button() == Qt::RightButton)
{
qDebug() << event;
}
}
void PowerSystem::contextMenuEvent(QContextMenuEvent *event)
{
QMenu *menu = new QMenu(this);
QAction *pAction = new QAction("float",this);
connect(pAction,SIGNAL(triggered(bool)),
this,SLOT(setFloat()));
menu->addAction(pAction);
menu->move(cursor().pos());
menu->show();
}
void PowerSystem::setFloat(void)
{
if(this->parent())
{
this->setParent(nullptr);
}
else
{
this->setParent(par);
this->move(0,0);
}
this->show();
}
+22 -1
View File
@@ -1,7 +1,13 @@
#ifndef POWERSYSTEM_H #ifndef POWERSYSTEM_H
#define POWERSYSTEM_H #define POWERSYSTEM_H
#include <QWidget> #include <QWidget>
#include "QMouseEvent"
#include "QDebug"
#include "QAction"
#include "QContextMenuEvent"
#include "QMenu"
namespace Ui { namespace Ui {
class PowerSystem; class PowerSystem;
@@ -15,7 +21,22 @@ public:
explicit PowerSystem(QWidget *parent = nullptr); explicit PowerSystem(QWidget *parent = nullptr);
~PowerSystem(); ~PowerSystem();
void mousePressEvent(QMouseEvent *event);
void contextMenuEvent(QContextMenuEvent *event);
private slots:
public slots:
void setFloat(void);
private: private:
QWidget *par;
Ui::PowerSystem *ui; Ui::PowerSystem *ui;
}; };
+16 -1
View File
@@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>728</width> <width>728</width>
<height>552</height> <height>546</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@@ -21,6 +21,9 @@
<property name="title"> <property name="title">
<string>控制指令</string> <string>控制指令</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<layout class="QGridLayout" name="gridLayout_3"> <layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="2"> <item row="0" column="2">
<widget class="QPushButton" name="pushButton_coldrun"> <widget class="QPushButton" name="pushButton_coldrun">
@@ -133,6 +136,9 @@
<property name="title"> <property name="title">
<string>测试指令</string> <string>测试指令</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<layout class="QGridLayout" name="gridLayout_4"> <layout class="QGridLayout" name="gridLayout_4">
<item row="1" column="1"> <item row="1" column="1">
<widget class="QComboBox" name="comboBox_5"/> <widget class="QComboBox" name="comboBox_5"/>
@@ -389,6 +395,9 @@
<property name="title"> <property name="title">
<string>其他状态</string> <string>其他状态</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<property name="spacing"> <property name="spacing">
<number>10</number> <number>10</number>
@@ -710,6 +719,9 @@
<property name="title"> <property name="title">
<string>告警状态</string> <string>告警状态</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<layout class="QGridLayout" name="gridLayout_6"> <layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0"> <item row="0" column="0">
<widget class="QCheckBox" name="checkBox_1"> <widget class="QCheckBox" name="checkBox_1">
@@ -801,6 +813,9 @@
<property name="title"> <property name="title">
<string>故障状态</string> <string>故障状态</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<layout class="QGridLayout" name="gridLayout_7"> <layout class="QGridLayout" name="gridLayout_7">
<item row="12" column="0"> <item row="12" column="0">
<widget class="QCheckBox" name="checkBox_19"> <widget class="QCheckBox" name="checkBox_19">
+14
View File
@@ -0,0 +1,14 @@
#include "ServoSystem.h"
#include "ui_ServoSystem.h"
ServoSystem::ServoSystem(QWidget *parent) :
QWidget(parent),
ui(new Ui::ServoSystem)
{
ui->setupUi(this);
}
ServoSystem::~ServoSystem()
{
delete ui;
}
+22
View File
@@ -0,0 +1,22 @@
#ifndef SERVOSYSTEM_H
#define SERVOSYSTEM_H
#include <QWidget>
namespace Ui {
class ServoSystem;
}
class ServoSystem : public QWidget
{
Q_OBJECT
public:
explicit ServoSystem(QWidget *parent = nullptr);
~ServoSystem();
private:
Ui::ServoSystem *ui;
};
#endif // SERVOSYSTEM_H
+35
View File
@@ -0,0 +1,35 @@
QT += opengl
QT += network
QT += sql
QT += svg
QT += quickwidgets
QT += quick
QT += qml
FORMS += \
$$PWD/ServoSystem.ui
HEADERS += \
$$PWD/ServoSystem.h
SOURCES += \
$$PWD/ServoSystem.cpp
+266
View File
@@ -0,0 +1,266 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ServoSystem</class>
<widget class="QWidget" name="ServoSystem">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>649</width>
<height>420</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>621</width>
<height>191</height>
</rect>
</property>
<property name="title">
<string>电源</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>模块温度</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_2">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>56V供电打开</string>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QPushButton" name="pushButton_2">
<property name="text">
<string>56V供电关闭</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>地面28V电压</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_4">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="label_5">
<property name="text">
<string>地面28V电流</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QLabel" name="label_6">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QPushButton" name="pushButton_3">
<property name="text">
<string>空速加热打开</string>
</property>
</widget>
</item>
<item row="1" column="5">
<widget class="QPushButton" name="pushButton_4">
<property name="text">
<string>空速加热关闭</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>机载28V电压</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="label_10">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="label_7">
<property name="text">
<string>机载28V电流</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QLabel" name="label_9">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_12">
<property name="text">
<string>机载58V电压</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="label_14">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QLabel" name="label_11">
<property name="text">
<string>机载56V电流</string>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QLabel" name="label_13">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>地面电源</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QCheckBox" name="checkBox_2">
<property name="text">
<string>机载电源</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QCheckBox" name="checkBox_3">
<property name="text">
<string>28V电源</string>
</property>
</widget>
</item>
<item row="4" column="3">
<widget class="QCheckBox" name="checkBox_4">
<property name="text">
<string>56V电源</string>
</property>
</widget>
</item>
<item row="4" column="4">
<widget class="QCheckBox" name="checkBox_5">
<property name="text">
<string>空速管加热</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QGroupBox" name="groupBox_2">
<property name="geometry">
<rect>
<x>20</x>
<y>220</y>
<width>581</width>
<height>141</height>
</rect>
</property>
<property name="title">
<string>舵机</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<widget class="QPushButton" name="pushButton_5">
<property name="geometry">
<rect>
<x>50</x>
<y>20</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>PushButton</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_6">
<property name="geometry">
<rect>
<x>150</x>
<y>20</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>PushButton</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_7">
<property name="geometry">
<rect>
<x>240</x>
<y>20</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>PushButton</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_8">
<property name="geometry">
<rect>
<x>330</x>
<y>20</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>PushButton</string>
</property>
</widget>
</widget>
</widget>
<resources/>
<connections/>
</ui>
+8 -1
View File
@@ -33,7 +33,8 @@ ToolsUI::ToolsUI(QWidget *parent) :
powersystem = new PowerSystem(ui->frame); powersystem = new PowerSystem(ui->frame);
powersystem->hide(); powersystem->hide();
servosystem = new ServoSystem(ui->frame);
servosystem->hide();
//connect(index4,SIGNAL(destroyed(QObject*))) //connect(index4,SIGNAL(destroyed(QObject*)))
@@ -88,6 +89,9 @@ void ToolsUI::resizeEvent(QResizeEvent *event)
powersystem->setGeometry(0,0,ui->frame->geometry().width(),ui->frame->geometry().height()); powersystem->setGeometry(0,0,ui->frame->geometry().width(),ui->frame->geometry().height());
servosystem->setGeometry(0,0,ui->frame->geometry().width(),ui->frame->geometry().height());
update(); update();
} }
@@ -119,6 +123,9 @@ void ToolsUI::onTabIndexChanged(const int &index)//界面选择管理
if(index == 5) powersystem->show(); if(index == 5) powersystem->show();
else powersystem->hide(); else powersystem->hide();
if(index == 6) servosystem->show();
else servosystem->hide();
} }
+2
View File
@@ -11,6 +11,7 @@
#include "tools_Index3.h" #include "tools_Index3.h"
#include "tools_Index4.h" #include "tools_Index4.h"
#include "PowerSystem/PowerSystem.h" #include "PowerSystem/PowerSystem.h"
#include "ServoSystem/ServoSystem.h"
namespace Ui { namespace Ui {
class ToolsUI; class ToolsUI;
@@ -34,6 +35,7 @@ public:
PowerSystem *powersystem = nullptr; PowerSystem *powersystem = nullptr;
ServoSystem *servosystem = nullptr;
private slots: private slots:
+1 -1
View File
@@ -14,7 +14,7 @@ include (./tools_Index2/tools_Index2.pri)
include (./tools_Index3/tools_Index3.pri) include (./tools_Index3/tools_Index3.pri)
include (./tools_Index4/tools_Index4.pri) include (./tools_Index4/tools_Index4.pri)
include (./PowerSystem/PowerSystem.pri) include (./PowerSystem/PowerSystem.pri)
include (./ServoSystem/ServoSystem.pri)
+1 -1
View File
@@ -140,7 +140,7 @@ int main(int argc, char *argv[])
a.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); a.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8")); QTextCodec::setCodecForLocale(QTextCodec::codecForName("system"));
LoadLang(&a); LoadLang(&a);
Binary file not shown.