删除,插入都不行
This commit is contained in:
+126
-36
@@ -7,6 +7,30 @@ MissionUI::MissionUI(QWidget *parent) :
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setWindowTitle(tr("Mission Table"));
|
||||
//setWindowFlags(windowFlags() & ~Qt::WindowStaysOnTopHint);
|
||||
//load qss
|
||||
|
||||
QFile file(":/qss/propertyui.qss");
|
||||
file.open(QFile::ReadOnly);
|
||||
QTextStream filetext(&file);
|
||||
QString stylesheet = filetext.readAll();
|
||||
this->setStyleSheet(stylesheet);
|
||||
file.close();
|
||||
|
||||
//this->setFocus();
|
||||
//this->setFocusPolicy(Qt::StrongFocus);
|
||||
|
||||
|
||||
|
||||
ui->pushButton_load->setFixedSize(80,40);
|
||||
ui->pushButton_save->setFixedSize(80,40);
|
||||
ui->pushButton_upload->setFixedSize(80,40);
|
||||
ui->pushButton_download->setFixedSize(80,40);
|
||||
ui->pushButton_insert->setFixedSize(80,40);
|
||||
ui->pushButton_delete->setFixedSize(80,40);
|
||||
ui->pushButton_clean->setFixedSize(80,40);
|
||||
ui->pushButton_add->setFixedSize(80,40);
|
||||
|
||||
|
||||
tablelist.insert(1,ui->tableWidget_1);
|
||||
tablelist.insert(3,ui->tableWidget_3);
|
||||
@@ -22,9 +46,13 @@ MissionUI::MissionUI(QWidget *parent) :
|
||||
table->setColumnCount(9); //设置列数为7
|
||||
table->setGeometry(QRect(10,455,740,95)); //设置tableWidget的大小
|
||||
table->setSelectionBehavior(QAbstractItemView::SelectRows);//设置选中模式为选中行
|
||||
table->setSelectionMode ( QAbstractItemView::SingleSelection); //设置选择模式,选择单行
|
||||
table->setAlternatingRowColors(true);
|
||||
table->setEditTriggers(QAbstractItemView::NoEditTriggers);//不能编辑
|
||||
table->setMouseTracking(true);
|
||||
//table->setFocusPolicy(Qt::NoFocus);
|
||||
table->setFocus();
|
||||
table->setFocusPolicy(Qt::StrongFocus);
|
||||
|
||||
table->setColumnWidth(0,45); //设置第一列的列宽(num)
|
||||
table->setColumnWidth(1,80); //设置第二列的列宽(cmd)
|
||||
@@ -38,7 +66,7 @@ MissionUI::MissionUI(QWidget *parent) :
|
||||
|
||||
|
||||
table->setHorizontalHeaderLabels(QStringList() <<tr("number")<<tr("command")<<tr("par1")<<tr("par2")<<tr("par3")<<tr("par4")<<tr("lat")<<tr("lng")<<tr("alt"));
|
||||
table->setFont(QFont("黑体",12,3)); //设置字体
|
||||
//table->setFont(QFont("黑体",15,3)); //设置字体
|
||||
QHeaderView* V_headerView = table->verticalHeader();
|
||||
V_headerView->setHidden(true); //行名隐藏
|
||||
|
||||
@@ -228,16 +256,11 @@ void MissionUI::setCurrent(int group,int idx)
|
||||
QTableWidget *widget = tablelist.value(group);
|
||||
if(widget)
|
||||
{
|
||||
/*
|
||||
|
||||
qDebug() << "select" << group << idx;
|
||||
|
||||
QTableWidgetItem *item = widget->item(idx,0);
|
||||
//widget->selectRow(idx-1);
|
||||
|
||||
if(item)
|
||||
{
|
||||
widget->setCurrentItem(item);
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -298,36 +321,101 @@ void MissionUI::on_pushButton_save_clicked()
|
||||
|
||||
void MissionUI::on_pushButton_upload_clicked()
|
||||
{
|
||||
emit WPUpload();
|
||||
emit WPUpload();
|
||||
}
|
||||
|
||||
void MissionUI::on_pushButton_download_clicked()
|
||||
{
|
||||
emit WPDownload();
|
||||
emit WPDownload();
|
||||
}
|
||||
|
||||
void MissionUI::on_pushButton_insert_clicked()
|
||||
{
|
||||
emit WPInsert();
|
||||
emit WPInsert();
|
||||
|
||||
//删除完成后,刷新一次所有航点
|
||||
emit getAllPoints();
|
||||
}
|
||||
|
||||
void MissionUI::on_pushButton_delete_clicked()
|
||||
{
|
||||
//清除一下,
|
||||
|
||||
QTableWidget *widget;
|
||||
//根据tabwidget
|
||||
int tab_idx =ui->tabWidget->currentIndex();
|
||||
|
||||
switch (tab_idx) {
|
||||
case 0:
|
||||
widget = tablelist.value(1);
|
||||
break;
|
||||
case 1:
|
||||
widget = tablelist.value(3);
|
||||
break;
|
||||
case 2:
|
||||
widget = tablelist.value(4);
|
||||
break;
|
||||
case 3:
|
||||
widget = tablelist.value(5);
|
||||
break;
|
||||
case 4:
|
||||
widget = tablelist.value(6);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
int idx = widget->currentRow();
|
||||
widget->removeRow(idx);
|
||||
|
||||
emit WPDelete();
|
||||
|
||||
//删除完成后,刷新一次所有航点
|
||||
emit getAllPoints();
|
||||
|
||||
}
|
||||
|
||||
void MissionUI::on_pushButton_add_clicked()
|
||||
{
|
||||
emit WPAdd();
|
||||
|
||||
//删除完成后,刷新一次所有航点
|
||||
emit getAllPoints();
|
||||
}
|
||||
|
||||
void MissionUI::on_pushButton_clean_clicked()
|
||||
{
|
||||
emit WPDeleteAll();
|
||||
QTableWidget *widget;
|
||||
//根据tabwidget
|
||||
int tab_idx =ui->tabWidget->currentIndex();
|
||||
|
||||
switch (tab_idx) {
|
||||
case 0:
|
||||
widget = tablelist.value(1);
|
||||
break;
|
||||
case 1:
|
||||
widget = tablelist.value(3);
|
||||
break;
|
||||
case 2:
|
||||
widget = tablelist.value(4);
|
||||
break;
|
||||
case 3:
|
||||
widget = tablelist.value(5);
|
||||
break;
|
||||
case 4:
|
||||
widget = tablelist.value(6);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
for (int i = 0;i < widget->rowCount();i++) {
|
||||
widget->removeRow(i);
|
||||
}
|
||||
|
||||
emit WPDeleteAll();
|
||||
|
||||
//删除完成后,刷新一次所有航点
|
||||
emit getAllPoints();
|
||||
}
|
||||
|
||||
|
||||
@@ -337,8 +425,6 @@ void MissionUI::itemSelectionChanged()
|
||||
int group = tablelist.key(widget);
|
||||
int idx = widget->currentRow() + 1;
|
||||
|
||||
//widget->selectionModel()->setCurrentIndex(idx, QItemSelectionModel::NoUpdate);
|
||||
|
||||
emit waypointSelect(group,idx);
|
||||
|
||||
}
|
||||
@@ -401,34 +487,38 @@ void MissionUI::itemDoubleClicked(QTableWidgetItem *item)
|
||||
{
|
||||
if(column == 1)
|
||||
{
|
||||
QComboBox *cmdBox = new QComboBox(widget);
|
||||
cmdBox->addItem(tr("航点"),16);
|
||||
cmdBox->addItem(tr("返航"),20);
|
||||
cmdBox->addItem(tr("降落"),21);
|
||||
cmdBox->addItem(tr("起飞"),22);
|
||||
cmdBox->setCurrentIndex(cmdBox->findText(itemValue.toString()));
|
||||
widget->removeCellWidget(row,column);
|
||||
widget->setCellWidget(row,column,cmdBox);
|
||||
QComboBox *combox = new QComboBox(widget);
|
||||
combox->addItem(tr("航点"),16);
|
||||
combox->addItem(tr("返航"),20);
|
||||
combox->addItem(tr("降落"),21);
|
||||
combox->addItem(tr("起飞"),22);
|
||||
combox->setCurrentIndex(combox->findText(itemValue.toString()));
|
||||
combox->setStyleSheet("background-color: #FFFFFF;font :15px 黑体;");
|
||||
|
||||
connect(cmdBox,&QComboBox::currentTextChanged,[=]{
|
||||
QString str = cmdBox->currentText();
|
||||
widget->removeCellWidget(row,column);
|
||||
widget->setCellWidget(row,column,combox);
|
||||
|
||||
connect(combox,&QComboBox::currentTextChanged,[=]{
|
||||
QString str = combox->currentText();
|
||||
emit setCommand(str);//直接修改底层,让底层返回数据更新到界面
|
||||
});
|
||||
}
|
||||
else if(column == 2)
|
||||
{
|
||||
QComboBox *par1Box = new QComboBox(widget);
|
||||
par1Box->addItem(tr("保持"),0);
|
||||
par1Box->addItem(tr("表速"),-1);
|
||||
par1Box->addItem(tr("快升"),-2);
|
||||
par1Box->addItem(tr("开加力"),-3);
|
||||
par1Box->addItem(tr("关加力"),-4);
|
||||
par1Box->setCurrentIndex(par1Box->findText(itemValue.toString()));
|
||||
widget->removeCellWidget(row,column);
|
||||
widget->setCellWidget(row,column,par1Box);
|
||||
QComboBox *combox = new QComboBox(widget);
|
||||
combox->addItem(tr("保持"),0);
|
||||
combox->addItem(tr("表速"),-1);
|
||||
combox->addItem(tr("快升"),-2);
|
||||
combox->addItem(tr("开加力"),-3);
|
||||
combox->addItem(tr("关加力"),-4);
|
||||
combox->setCurrentIndex(combox->findText(itemValue.toString()));
|
||||
combox->setStyleSheet("background-color: #FFFFFF;font :15px 黑体;");
|
||||
|
||||
connect(par1Box,&QComboBox::currentTextChanged,[=]{
|
||||
QString str = par1Box->currentText();
|
||||
widget->removeCellWidget(row,column);
|
||||
widget->setCellWidget(row,column,combox);
|
||||
|
||||
connect(combox,&QComboBox::currentTextChanged,[=]{
|
||||
QString str = combox->currentText();
|
||||
emit setParam1(str);
|
||||
});
|
||||
}
|
||||
|
||||
+93
-57
@@ -14,6 +14,18 @@
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="8" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
@@ -79,69 +91,30 @@
|
||||
<item row="0" column="1" rowspan="20">
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
<number>4</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string>Rectangle</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QTableWidget" name="tableWidget_1">
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="midLineWidth">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::DoubleClicked</set>
|
||||
</property>
|
||||
<property name="tabKeyNavigation">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="showDropIndicator" stdset="0">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="verticalScrollMode">
|
||||
<enum>QAbstractItemView::ScrollPerPixel</enum>
|
||||
</property>
|
||||
<property name="showGrid">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="gridStyle">
|
||||
<enum>Qt::SolidLine</enum>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="cornerButtonEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderCascadingSectionResizes">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderShowSortIndicator" stdset="0">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderCascadingSectionResizes">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderShowSortIndicator" stdset="0">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@@ -151,8 +124,23 @@
|
||||
<string>Mission 1</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<property name="leftMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QTableWidget" name="tableWidget_3">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
@@ -165,8 +153,24 @@
|
||||
<string>Mssion 2</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<property name="leftMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QTableWidget" name="tableWidget_4"/>
|
||||
<widget class="QTableWidget" name="tableWidget_4">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
@@ -175,8 +179,24 @@
|
||||
<string>Mssion 3</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_6">
|
||||
<property name="leftMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QTableWidget" name="tableWidget_5"/>
|
||||
<widget class="QTableWidget" name="tableWidget_5">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
@@ -185,8 +205,24 @@
|
||||
<string>Mission 4</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_7">
|
||||
<property name="leftMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QTableWidget" name="tableWidget_6"/>
|
||||
<widget class="QTableWidget" name="tableWidget_6">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
||||
@@ -39,9 +39,27 @@
|
||||
}
|
||||
|
||||
|
||||
.QHeaderView {
|
||||
background-color: #FFFFFF;
|
||||
font: 15px "黑体";
|
||||
}
|
||||
|
||||
|
||||
.QTabWidget {
|
||||
background-color: #FFFFFF;
|
||||
font: 15px "黑体";
|
||||
}
|
||||
|
||||
.QTableWidget {
|
||||
background-color: #FFFFFF;
|
||||
font: 15px "黑体";
|
||||
}
|
||||
|
||||
|
||||
.QComBox {
|
||||
background-color: #FFFFFF;
|
||||
font :15px "黑体";
|
||||
}
|
||||
|
||||
.QLabel {
|
||||
background-color: #FFFFFF;
|
||||
|
||||
Reference in New Issue
Block a user