支持添加多个图头表格

This commit is contained in:
jiayulong 2025-11-10 15:51:41 +08:00
parent d908a3a84a
commit 298e0b1cf1
9 changed files with 449 additions and 406 deletions

View File

@ -629,22 +629,15 @@ void FormDraw::addRandomGraph(QMyCustomPlot *widget, QVector<double> x, QVector<
else else
{ {
widget->graph()->setLineStyle((QCPGraph::LineStyle)(1));//曲线 widget->graph()->setLineStyle((QCPGraph::LineStyle)(1));//曲线
//widget->graph()->setLineStyle((QCPGraph::LineStyle)(std::rand()%5+1));
//widget->graph()->setLineStyle((QCPGraph::LineStyle)(QCPGraph::lsLine));//曲线
//widget->graph()->setLineStyle((QCPGraph::LineStyle)(QCPGraph::lsImpulse));//杆状
// if (std::rand()%100 > 50)
// widget->graph()->setScatterStyle(QCPScatterStyle((QCPScatterStyle::ScatterShape)(std::rand()%14+1)));
widget->graph()->setScatterStyle(QCPScatterStyle((QCPScatterStyle::ScatterShape)(1))); widget->graph()->setScatterStyle(QCPScatterStyle((QCPScatterStyle::ScatterShape)(1)));
// widget->graph()->setScatterStyle(QCPScatterStyle(QPixmap(":/image/file.png"))); // widget->graph()->setScatterStyle(QCPScatterStyle(QPixmap(":/image/file.png")));
//widget->graph()->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssDisc, 5)); //widget->graph()->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssDisc, 5));
QPen graphPen; QPen graphPen;
newlineColor = QColor(std::rand()%245+10, std::rand()%245+10, std::rand()%245+10); newlineColor = QColor(std::rand()%245+10, std::rand()%245+10, std::rand()%245+10);
graphPen.setColor(newlineColor); graphPen.setColor(newlineColor);
//graphPen.setWidthF(std::rand()/(double)RAND_MAX*2+1);
width = 2; width = 2;
graphPen.setWidthF(width); graphPen.setWidthF(width);
graphPen.setStyle(Qt::SolidLine);//实线 graphPen.setStyle(Qt::SolidLine);//实线

View File

@ -3,8 +3,15 @@
#include <QMessageBox> #include <QMessageBox>
#include <QMenu> #include <QMenu>
#include "CallManage.h" #include "CallManage.h"
#include <QTimer>
//demo画道暂时不用 //extern int g_iRows;
//extern int g_iCols;
int g_iColsWidth=200;
int g_iRowsHight=80;
//画图头
FormHead::FormHead(QWidget *parent, int indexID) : FormHead::FormHead(QWidget *parent, int indexID) :
QWidget(parent), QWidget(parent),
ui(new Ui::FormHead) ui(new Ui::FormHead)
@ -13,13 +20,21 @@ FormHead::FormHead(QWidget *parent, int indexID) :
m_indexID =indexID; m_indexID =indexID;
//设置样式表,不显示竖直边框
ui->tableWidget->setStyleSheet( "QTableView::item {border-left: 0px solid black;} \
QTableView::item:selected {border-left: 0px solid black;}\
QTableView::item {border-right: 0px solid black;} \
QTableView::item:selected {border-right: 0px solid black;}");
//使能右键菜单功能 //使能右键菜单功能
ui->tableWidget->setContextMenuPolicy(Qt::CustomContextMenu); ui->tableWidget->setContextMenuPolicy(Qt::CustomContextMenu);
// 连接信号和槽 // 连接信号和槽
connect(ui->tableWidget, &QTableWidget::itemClicked, this, &FormHead::onItemClicked);
// 创建并设置定时器
// m_timer = new QTimer(this);
// connect(m_timer, &QTimer::timeout, this, &FormHead::resizeWindow);
// m_timer->start(5); // 设置定时器为5毫秒
} }
FormHead::~FormHead() FormHead::~FormHead()
@ -27,80 +42,56 @@ FormHead::~FormHead()
delete ui; delete ui;
} }
void FormHead::resizeWindow()
void FormHead::Init()
{ {
QRect rect = this->rect();
//调整大小
if(rect.width()>m_iCols*g_iColsWidth)
{
ui->tableWidget->setGeometry((rect.width()-(m_iCols*g_iColsWidth+1))/2, 0, m_iCols*(g_iColsWidth+1), m_iRows*(g_iRowsHight+2));
}
else
{
ui->tableWidget->setGeometry(0, 0, m_iCols*(g_iColsWidth+1), m_iRows*(g_iRowsHight+2));
}
//m_timer->stop();
}
void FormHead::resizeEvent(QResizeEvent *event)
{
resizeWindow();
}
void FormHead::Init(int iRows, int iCols, int iWidth)
{
m_iRows =iRows;
m_iCols = iCols;
//清空 //清空
ui->tableWidget->clearContents(); ui->tableWidget->clearContents();
ui->tableWidget->verticalHeader()->hide();//隐藏左侧系统序号栏 ui->tableWidget->verticalHeader()->hide();//隐藏左侧系统序号栏
ui->tableWidget->horizontalHeader()->hide();//隐藏上方系统序号栏 ui->tableWidget->horizontalHeader()->hide();//隐藏上方系统序号栏
//ui->tableWidget->verticalHeader()->setFixedWidth(3);//标题栏宽度
//ui->tableWidget->horizontalHeader()->setFixedHeight(3);//标题栏高度
//QRect rect = this->rect();
//因为tableWidget需要提前规定好行数与列数 //因为tableWidget需要提前规定好行数与列数
int recordcount = 0; //总行数 ui->tableWidget->setColumnCount(m_iCols);//列数
ui->tableWidget->setColumnCount(1); ui->tableWidget->setRowCount(m_iRows); //动态设置行数
ui->tableWidget->setRowCount(recordcount); //动态设置行数
//设置所有列均匀分布并填充满整个空间 for(int i=0; i<m_iRows; i++)
QHeaderView *header = ui->tableWidget->horizontalHeader();
for (int i = 0; i < ui->tableWidget->columnCount(); ++i) {
header->setSectionResizeMode(i, QHeaderView::Stretch);
}
}
void FormHead::Add(QString strLineName, QColor lineColor)
{ {
int row = ui->tableWidget->rowCount(); //设置高度
ui->tableWidget->setRowCount(row + 1); ui->tableWidget->setRowHeight(i, g_iRowsHight);
QFont font("微软雅黑", 12, QFont::Bold, false); for(int j=0; j<m_iCols; j++)
//QColor _fontColor = QColor(220, 220, 220);
//
QTableWidgetItem* item = new QTableWidgetItem(strLineName);
item->setFlags(item->flags() & (~Qt::ItemIsEditable));
item->setForeground(QBrush(lineColor));// 设置字体颜色
item->setFont(font); // 应用新的字体
item->setTextAlignment(Qt::AlignCenter);//居中
//
ui->tableWidget->setItem(row, 0, item);
}
// 槽函数
void FormHead::onItemClicked(QTableWidgetItem *item)
{ {
if (item) { //设置列宽
// 获取 item 的位置信息 ui->tableWidget->setColumnWidth(j, g_iColsWidth);
//int row = item->row();
//int column = item->column();
// 处理 item 点击的逻辑
//qDebug() << "Item at row" << row << "column" << column << "clicked.";
QString message = "选中项: " + item->text(); QTableWidgetItem* item = new QTableWidgetItem("");
ui->tableWidget->setItem(i, j, item);
QMessageBox::information(this, "提示", message);
} }
} }
void FormHead::on_tableWidget_customContextMenuRequested(const QPoint &pos)
{
QMenu *menu = new QMenu(ui->tableWidget);
QAction *actionAddLine = menu->addAction(tr("新增曲线"));
//QAction *actionDel = menu->addAction(tr("删除道"));
connect(actionAddLine, SIGNAL(triggered()), this, SLOT(s_AddLine()));
//connect(actionDel, SIGNAL(triggered()), this, SLOT(s_DelOne()));
menu->exec(QCursor::pos());
}
void FormHead::s_AddLine()
{
emit CallManage::getInstance()->sig_AddLine(m_indexID);
}
void FormHead::s_DelOne()
{
emit CallManage::getInstance()->sig_DelOne(m_indexID);
} }

View File

@ -23,18 +23,17 @@ private:
public: public:
int m_indexID; int m_indexID;
int m_iRows;
int m_iCols;
QTimer *m_timer;
public: public:
void Init(); void Init(int iRows, int iCols, int iWidth);
void Add(QString strLineName, QColor lineColor); void resizeEvent(QResizeEvent *event);
public slots: public slots:
void onItemClicked(QTableWidgetItem *item); void resizeWindow();
void s_AddLine();
void s_DelOne();
private slots:
void on_tableWidget_customContextMenuRequested(const QPoint &pos);
}; };
#endif // FORMHEAD_H #endif // FORMHEAD_H

View File

@ -14,51 +14,16 @@
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>0</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="0" column="0"> <item row="0" column="0">
<widget class="QTableWidget" name="tableWidget"> <widget class="QTableWidget" name="tableWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">QTableCornerButton::section <string notr="true"/>
{
background-color: #0770CC;
color:#FFFFFF;
border:1px solid #1d6382;
}
QTableWidget
{
color: #FFFFFF;
gridline-color: #1d6382;
border: 1px solid #1d6382 ;
background-color: #0770CC;
}
QTableWidget::item
{
padding-left:5px
}
QTableWidget::item:hover,QListView::item:hover,QTreeView::item:hover,QHeaderView,QHeaderView::section,QTableCornerButton:section{
color:#FFFFFF;
background:#0770CC;
}
QTableWidget::item:selected
{
background-color: #0770CC;
color:#FFFFFF;
}</string>
</property> </property>
</widget> </widget>
</item> </item>

View File

@ -37,6 +37,7 @@ SOURCES += \
customtabwidget.cpp \ customtabwidget.cpp \
fileedit.cpp \ fileedit.cpp \
formdraw.cpp \ formdraw.cpp \
formhead.cpp \
forminfo.cpp \ forminfo.cpp \
formline.cpp \ formline.cpp \
formtrack.cpp \ formtrack.cpp \
@ -68,6 +69,7 @@ HEADERS += \
customtabwidget.h \ customtabwidget.h \
fileedit.h \ fileedit.h \
formdraw.h \ formdraw.h \
formhead.h \
forminfo.h \ forminfo.h \
formline.h \ formline.h \
formtrack.h \ formtrack.h \
@ -91,15 +93,12 @@ FORMS += \
formhead.ui \ formhead.ui \
forminfo.ui \ forminfo.ui \
formline.ui \ formline.ui \
formtitle.ui \
formtrack.ui \ formtrack.ui \
formwell.ui \ formwell.ui \
interfaceWidget.ui \ interfaceWidget.ui \
mainwindow.ui \ mainwindow.ui \
mainwindowcurve.ui \ mainwindowcurve.ui \
mainwindownew.ui \
newheaddialog.ui \ newheaddialog.ui \
qtcenterwidgets.ui \
qtprojectwidgets.ui qtprojectwidgets.ui
INCLUDEPATH += ../include/ \ INCLUDEPATH += ../include/ \

View File

@ -39,7 +39,7 @@ int g_iY1 = -3000;
int g_iY2 = 0; int g_iY2 = 0;
int g_iCanZoom = 0; int g_iCanZoom = 0;
int g_iScale = 1000; int g_iScale = 3000;
QString g_prjname=""; QString g_prjname="";
MainWindow::MainWindow(QWidget *parent) : MainWindow::MainWindow(QWidget *parent) :

View File

@ -8,6 +8,8 @@
#include <QFuture> #include <QFuture>
#include <QtConcurrent/QtConcurrent> #include <QtConcurrent/QtConcurrent>
#include "newheaddialog.h" #include "newheaddialog.h"
#include "formhead.h"
#include "qmytablewidget.h"
extern int g_iOneWidth; //道宽 extern int g_iOneWidth; //道宽
extern QString g_prjname; extern QString g_prjname;
@ -19,6 +21,8 @@ extern int g_iScale;
extern int g_iRows; extern int g_iRows;
extern int g_iCols; extern int g_iCols;
extern int g_iColsWidth;
extern int g_iRowsHight;
MainWindowCurve::MainWindowCurve(QWidget *parent) : MainWindowCurve::MainWindowCurve(QWidget *parent) :
QMainWindow(parent), QMainWindow(parent),
@ -41,9 +45,26 @@ MainWindowCurve::MainWindowCurve(QWidget *parent) :
//------------------------------------- //-------------------------------------
ui->tableWidget->hide(); ui->tableWidget->hide();
//隐藏网格线
ui->tableWidget->setShowGrid(false);
//设置样式表,不显示竖直边框
ui->tableWidget->setStyleSheet( "QTableView::item {border-left: 0px solid black;} \
QTableView::item:selected {border-left: 0px solid black;}\
QTableView::item {border-right: 0px solid black;} \
QTableView::item:selected {border-right: 0px solid black;}");
// //
ui->tableWidget->verticalHeader()->hide(); ui->tableWidget->verticalHeader()->hide(); //行
ui->tableWidget->horizontalHeader()->hide(); ui->tableWidget->horizontalHeader()->hide(); //列
//ui->tableWidget->verticalHeader()->setFixedWidth(3);//标题栏宽度
//ui->tableWidget->horizontalHeader()->setFixedHeight(3);//标题栏高度
ui->tableWidget->setColumnCount(1); //动态设置列数
ui->tableWidget->horizontalHeader()->setStretchLastSection(true);//最后一列铺满最后
//标题
QTableWidgetItem *headerItem = new QTableWidgetItem("");
ui->tableWidget->setHorizontalHeaderItem(0, headerItem);
//我们让一列也可以滑动
ui->tableWidget->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
ui->tableWidget->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
// 设置右键菜单策略 // 设置右键菜单策略
ui->tableWidget->setContextMenuPolicy(Qt::CustomContextMenu); ui->tableWidget->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->tableWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(slotContextMenu(QPoint))); connect(ui->tableWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(slotContextMenu(QPoint)));
@ -69,6 +90,7 @@ MainWindowCurve::MainWindowCurve(QWidget *parent) :
//我们让一列也可以滑动 //我们让一列也可以滑动
ui->tableWidget_2->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); ui->tableWidget_2->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
ui->tableWidget_2->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); ui->tableWidget_2->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
// //表头 // //表头
// QStringList list; // QStringList list;
// list << "" << "" << "" << ""; // list << "" << "" << "" << "";
@ -280,6 +302,30 @@ void MainWindowCurve::s_showHeadTable()
else { else {
ui->tableWidget->show(); ui->tableWidget->show();
} }
// QTableWidget *tableWidget = new QTableWidget();
// tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
// tableWidget->verticalHeader()->setSectionResizeMode(QHeaderView::Stretch);
// tableWidget->setRowCount(5);
// tableWidget->setColumnCount(5);
// for(int i=0; i<5; i++)
// {
// //tableWidget->setColumnWidth(i, 100);
// for(int j=0; j<5; j++)
// {
// QTableWidgetItem* item = new QTableWidgetItem("");
// tableWidget->setItem(i, j, item);
// }
// }
//// QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); // 首选大小策略
//// sizePolicy.setHorizontalStretch(0); // 水平拉伸因子
//// sizePolicy.setVerticalStretch(0); // 垂直拉伸因子
//// tableWidget->setSizePolicy(sizePolicy);
// ui->verticalLayout_head->addWidget(tableWidget, 0, Qt::AlignCenter); // 通过布局添加表格
} }
QJsonObject MainWindowCurve::makeJson() QJsonObject MainWindowCurve::makeJson()
@ -555,10 +601,7 @@ void MainWindowCurve::dropEvent(QDropEvent* event)
//QApplication::restoreOverrideCursor(); //QApplication::restoreOverrideCursor();
} }
void MainWindowCurve::slotContextMenu(QPoint pos) void MainWindowCurve::slotContextMenu(QPoint pos)
{
if(ui->tableWidget->rowCount()==0 && ui->tableWidget->rowCount()==0)
{ {
QMenu menu(ui->tableWidget); QMenu menu(ui->tableWidget);
QAction *newAction = menu.addAction("新建图头"); QAction *newAction = menu.addAction("新建图头");
@ -572,20 +615,37 @@ void MainWindowCurve::slotContextMenu(QPoint pos)
if (result == QDialog::Accepted) { if (result == QDialog::Accepted) {
// 处理用户点击了确定按钮的逻辑 // 处理用户点击了确定按钮的逻辑
qDebug() << "Accepted="; qDebug() << "Accepted=";
//
ui->tableWidget->clear();
//
ui->tableWidget->setColumnCount(g_iCols);
ui->tableWidget->setRowCount(g_iRows); //动态设置行数
for(int i=0; i<g_iRows; i++)
{
for(int j=0; j<g_iCols; j++)
{
QTableWidgetItem* item = new QTableWidgetItem("");
ui->tableWidget->setItem(i, j, item);
}
}
int rowcount = ui->tableWidget->rowCount(); //总行数
//增加1行
ui->tableWidget->setRowCount(rowcount+1);
//行标题
QTableWidgetItem *headerItem = new QTableWidgetItem("");
ui->tableWidget->setVerticalHeaderItem(rowcount, headerItem);
int iWidth=0;
//设置行高度
ui->tableWidget->setRowHeight(rowcount, g_iRows*(g_iRowsHight+2)+1);
if(rowcount==0)
{
iWidth=g_iCols*g_iColsWidth;
//设置列宽
ui->tableWidget->setColumnWidth(0, g_iCols*(g_iColsWidth+1)+1);
}
else
{
iWidth=ui->tableWidget->columnWidth(0);
if(iWidth<g_iCols*g_iColsWidth)//列宽变大
{
iWidth=g_iCols*g_iColsWidth;
//设置列宽
ui->tableWidget->setColumnWidth(0, g_iCols*(g_iColsWidth+1)+1);
}
}
//
FormHead *widgetHead = new FormHead(this, 1);
widgetHead->Init(g_iRows, g_iCols, iWidth);
ui->tableWidget->setCellWidget(rowcount, 0, widgetHead);
} }
else if (result == QDialog::Rejected) { else if (result == QDialog::Rejected) {
// 处理用户点击了取消按钮的逻辑 // 处理用户点击了取消按钮的逻辑
@ -596,254 +656,293 @@ void MainWindowCurve::slotContextMenu(QPoint pos)
qDebug() << "other="; qDebug() << "other=";
} }
} }
}
else
{
QMenu menu(ui->tableWidget);
QAction *mergeAction = menu.addAction("合并表格");
QAction *refreshAction = menu.addAction("拆分表格");
QAction *deleteAction = menu.addAction("删除行");
QAction *addAction = menu.addAction("添加行");
// 弹出菜单 // if(ui->tableWidget->rowCount()==0 && ui->tableWidget->rowCount()==0)
QAction *selectedAction = menu.exec(ui->tableWidget->mapToGlobal(pos)); // {
// QMenu menu(ui->tableWidget);
// QAction *newAction = menu.addAction("新建图头");
// // 弹出菜单
// QAction *selectedAction = menu.exec(ui->tableWidget->mapToGlobal(pos));
// if (selectedAction == newAction) {
// NewHeadDialog *dlg = new NewHeadDialog(this);
// //
// dlg->setAttribute(Qt::WA_DeleteOnClose);//关闭时,自动删除窗口对象
// int result = dlg->exec();//模态对话框
// if (result == QDialog::Accepted) {
// // 处理用户点击了确定按钮的逻辑
// qDebug() << "Accepted=";
// //
// ui->tableWidget->clear();
// //
// ui->tableWidget->setColumnCount(g_iCols);
// ui->tableWidget->setRowCount(g_iRows); //动态设置行数
// for(int i=0; i<g_iRows; i++)
// {
// for(int j=0; j<g_iCols; j++)
// {
// QTableWidgetItem* item = new QTableWidgetItem("");
// ui->tableWidget->setItem(i, j, item);
// }
// }
if (selectedAction == mergeAction) { // }
qDebug() << "合并表格"; // else if (result == QDialog::Rejected) {
slotMerge(); // // 处理用户点击了取消按钮的逻辑
} else if (selectedAction == deleteAction) { // qDebug() << "Rejected=";
//删除1行 // }
int row = ui->tableWidget->currentRow(); // else {
ui->tableWidget->removeRow(row); // // 处理其他情况的逻辑
} else if (selectedAction == refreshAction) { // qDebug() << "other=";
qDebug() << "拆分表格"; // }
slotSplit(); // }
} // }
} // else
// {
// QMenu menu(ui->tableWidget);
// QAction *mergeAction = menu.addAction("合并表格");
// QAction *refreshAction = menu.addAction("拆分表格");
// QAction *deleteAction = menu.addAction("删除行");
// QAction *addAction = menu.addAction("添加行");
// // 弹出菜单
// QAction *selectedAction = menu.exec(ui->tableWidget->mapToGlobal(pos));
// if (selectedAction == mergeAction) {
// qDebug() << "合并表格";
// slotMerge();
// } else if (selectedAction == deleteAction) {
// //删除1行
// int row = ui->tableWidget->currentRow();
// ui->tableWidget->removeRow(row);
// } else if (selectedAction == refreshAction) {
// qDebug() << "拆分表格";
// slotSplit();
// }
// }
} }
//合并 //合并
void MainWindowCurve::slotMerge() void MainWindowCurve::slotMerge()
{ {
QModelIndexList list = ui->tableWidget->selectionModel()->selectedIndexes(); // QModelIndexList list = ui->tableWidget->selectionModel()->selectedIndexes();
if (list.size() < 2) // if (list.size() < 2)
{ // {
QMessageBox::warning(this, "单元格合并", "所选中单元格中为单个单元格,无法合并", "确定"); // QMessageBox::warning(this, "单元格合并", "所选中单元格中为单个单元格,无法合并", "确定");
return; // return;
} // }
int topRow = 0; // int topRow = 0;
int leftCol = 0; // int leftCol = 0;
int bottomRow = 0; // int bottomRow = 0;
int rightCol = 0; // int rightCol = 0;
QList<QTableWidgetSelectionRange> selectRanges = ui->tableWidget->selectedRanges(); // QList<QTableWidgetSelectionRange> selectRanges = ui->tableWidget->selectedRanges();
if (selectRanges.size() > 0) // if (selectRanges.size() > 0)
{ // {
topRow = selectRanges[0].topRow(); // topRow = selectRanges[0].topRow();
leftCol = selectRanges[0].leftColumn(); // leftCol = selectRanges[0].leftColumn();
bottomRow = selectRanges[0].bottomRow(); // bottomRow = selectRanges[0].bottomRow();
rightCol = selectRanges[0].rightColumn(); // rightCol = selectRanges[0].rightColumn();
} // }
for(auto range:selectRanges) // for(auto range:selectRanges)
{ // {
if(range.topRow()<topRow) // if(range.topRow()<topRow)
topRow=range.topRow(); // topRow=range.topRow();
if(range.leftColumn()<leftCol) // if(range.leftColumn()<leftCol)
leftCol=range.leftColumn(); // leftCol=range.leftColumn();
if(range.bottomRow()> bottomRow) // if(range.bottomRow()> bottomRow)
bottomRow=range.bottomRow(); // bottomRow=range.bottomRow();
if(range.rightColumn()>rightCol) // if(range.rightColumn()>rightCol)
rightCol=range.rightColumn(); // rightCol=range.rightColumn();
} // }
int rowSpan = (bottomRow - topRow) + 1; // int rowSpan = (bottomRow - topRow) + 1;
int colSpan = (rightCol - leftCol) + 1; // int colSpan = (rightCol - leftCol) + 1;
ui->tableWidget->setSpan(topRow, leftCol, rowSpan, colSpan); // ui->tableWidget->setSpan(topRow, leftCol, rowSpan, colSpan);
} }
//拆分 //拆分
void MainWindowCurve::slotSplit() void MainWindowCurve::slotSplit()
{ {
int row,col; // int row,col;
QList<QTableWidgetSelectionRange> selectRanges = ui->tableWidget->selectedRanges(); // QList<QTableWidgetSelectionRange> selectRanges = ui->tableWidget->selectedRanges();
if (selectRanges.size() < 2) // if (selectRanges.size() < 2)
{ // {
QMessageBox::warning(this, "拆分表格失败", "单元格已是最小单位,不能再进行拆分", "确定"); // QMessageBox::warning(this, "拆分表格失败", "单元格已是最小单位,不能再进行拆分", "确定");
return; // return;
} // }
QList<QTableWidgetItem*> selectItems = ui->tableWidget->selectedItems(); // QList<QTableWidgetItem*> selectItems = ui->tableWidget->selectedItems();
if(selectItems.size()==0) // if(selectItems.size()==0)
{ // {
QMessageBox::warning(this, "拆分表格失败", "请先为表格设置元素item", "确定"); // QMessageBox::warning(this, "拆分表格失败", "请先为表格设置元素item", "确定");
return; // return;
} // }
if(selectItems.size()>1) // if(selectItems.size()>1)
{ // {
QMessageBox::warning(this, "拆分表格失败", "非法选择", "确定"); // QMessageBox::warning(this, "拆分表格失败", "非法选择", "确定");
return; // return;
} // }
for(auto item:selectItems) // for(auto item:selectItems)
{ // {
row= item->row(); // row= item->row();
col=item->column(); // col=item->column();
} // }
ui->tableWidget->setSpan(row, col, 1, 1); // 设置跨度为1 // ui->tableWidget->setSpan(row, col, 1, 1); // 设置跨度为1
} }
bool MainWindowCurve::eventFilter(QObject* obj, QEvent* event) bool MainWindowCurve::eventFilter(QObject* obj, QEvent* event)
{ {
if (obj == ui->tableWidget && event->type() == QEvent::KeyPress) { // if (obj == ui->tableWidget && event->type() == QEvent::KeyPress) {
QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event); // QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
if (keyEvent->matches(QKeySequence::Paste)) { // if (keyEvent->matches(QKeySequence::Paste)) {
onPasteExcelData(); // onPasteExcelData();
return true; // return true;
} // }
} // }
return QMainWindow::eventFilter(obj, event); return QMainWindow::eventFilter(obj, event);
} }
//复制粘贴事件 //复制粘贴事件
void MainWindowCurve::keyPressEvent(QKeyEvent * event) void MainWindowCurve::keyPressEvent(QKeyEvent * event)
{ {
//excel 行分是 "\n" ; 列分是 "\t" // //excel 行分是 "\n" ; 列分是 "\t"
if (event->matches(QKeySequence::Copy)) // if (event->matches(QKeySequence::Copy))
{ // {
copy(); // copy();
} // }
else if (event->matches(QKeySequence::Paste)) // else if (event->matches(QKeySequence::Paste))
{ // {
Paste(); // Paste();
} // }
else if (event->matches(QKeySequence::SelectAll)) // else if (event->matches(QKeySequence::SelectAll))
{ // {
ui->tableWidget->selectAll(); // ui->tableWidget->selectAll();
} // }
else // else
{ // {
QWidget::keyPressEvent(event); // QWidget::keyPressEvent(event);
} // }
} }
void MainWindowCurve::copy() void MainWindowCurve::copy()
{ {
QMap<int, QList<int>> selMap;//行,列 // QMap<int, QList<int>> selMap;//行,列
QList<QTableWidgetItem*> list = ui->tableWidget->selectedItems(); // QList<QTableWidgetItem*> list = ui->tableWidget->selectedItems();
if (list.count() <= 0) // if (list.count() <= 0)
return; // return;
for (QTableWidgetItem* item : list) // for (QTableWidgetItem* item : list)
{ // {
int rowN = ui->tableWidget->row(item); // int rowN = ui->tableWidget->row(item);
int colN = ui->tableWidget->column(item); // int colN = ui->tableWidget->column(item);
selMap[rowN].append(colN); // selMap[rowN].append(colN);
} // }
QString cpStr; // QString cpStr;
QMap<int, QList<int>>::iterator it = selMap.begin(); // QMap<int, QList<int>>::iterator it = selMap.begin();
while (it != selMap.end()) // while (it != selMap.end())
{ // {
for (int i = 0; i < (*it).count(); i++) // for (int i = 0; i < (*it).count(); i++)
{ // {
QTableWidgetItem* item = ui->tableWidget->item(it.key(), (*it).at(i)); // QTableWidgetItem* item = ui->tableWidget->item(it.key(), (*it).at(i));
if (item) // if (item)
{ // {
cpStr.append(item->text().trimmed()); // cpStr.append(item->text().trimmed());
} // }
if (i != (*it).count() - 1) // if (i != (*it).count() - 1)
cpStr.append("\t"); // cpStr.append("\t");
} // }
it++; // it++;
if (it != selMap.end()) // if (it != selMap.end())
{ // {
cpStr.append("\n"); // cpStr.append("\n");
} // }
} // }
QApplication::clipboard()->setText(cpStr); // QApplication::clipboard()->setText(cpStr);
} }
void MainWindowCurve::Paste() void MainWindowCurve::Paste()
{ {
QString pastText = QApplication::clipboard()->text(); // QString pastText = QApplication::clipboard()->text();
QStringList rowList = pastText.split("\n", QString::KeepEmptyParts); // QStringList rowList = pastText.split("\n", QString::KeepEmptyParts);
if(rowList.size()==0) // if(rowList.size()==0)
{ // {
return; // return;
} // }
if(rowList.at(rowList.size()-1)=="") // if(rowList.at(rowList.size()-1)=="")
{ // {
rowList.removeAt(rowList.size()-1); // rowList.removeAt(rowList.size()-1);
} // }
QTableWidgetItem* crtItem = ui->tableWidget->currentItem(); // QTableWidgetItem* crtItem = ui->tableWidget->currentItem();
int rowN, colN; // int rowN, colN;
if (!crtItem) // if (!crtItem)
{ // {
rowN = ui->tableWidget->currentRow(); // rowN = ui->tableWidget->currentRow();
colN = ui->tableWidget->currentColumn(); // colN = ui->tableWidget->currentColumn();
} // }
else // else
{ // {
rowN = ui->tableWidget->row(crtItem); // rowN = ui->tableWidget->row(crtItem);
colN = ui->tableWidget->column(crtItem); // colN = ui->tableWidget->column(crtItem);
} // }
for (int i = 0; i < (ui->tableWidget->rowCount() - rowN) && (i < rowList.length()); i++) // for (int i = 0; i < (ui->tableWidget->rowCount() - rowN) && (i < rowList.length()); i++)
{ // {
QStringList rowDataList = rowList.at(i).split("\t", QString::KeepEmptyParts); // QStringList rowDataList = rowList.at(i).split("\t", QString::KeepEmptyParts);
for (int j = 0; j < (ui->tableWidget->columnCount() - colN) && (j < rowDataList.length()); j++) // for (int j = 0; j < (ui->tableWidget->columnCount() - colN) && (j < rowDataList.length()); j++)
{ // {
int x = i + rowN; // int x = i + rowN;
int y = j + colN; // int y = j + colN;
QTableWidgetItem* item = ui->tableWidget->item(x, y); // QTableWidgetItem* item = ui->tableWidget->item(x, y);
if (item) // if (item)
{ // {
item->setText(rowDataList.at(j)); // item->setText(rowDataList.at(j));
} // }
else // else
{ // {
ui->tableWidget->setItem(x, y, new QTableWidgetItem(rowDataList.at(j))); // ui->tableWidget->setItem(x, y, new QTableWidgetItem(rowDataList.at(j)));
} // }
} // }
} // }
} }
void MainWindowCurve::onPasteExcelData() void MainWindowCurve::onPasteExcelData()
{ {
QClipboard* clipboard = QApplication::clipboard(); // QClipboard* clipboard = QApplication::clipboard();
const QString clipData = clipboard->text(); // const QString clipData = clipboard->text();
if (clipData.isEmpty()) return; // if (clipData.isEmpty()) return;
QList<QStringList> rowsData; // QList<QStringList> rowsData;
const QStringList rows = clipData.split('\n', QString::SkipEmptyParts); // const QStringList rows = clipData.split('\n', QString::SkipEmptyParts);
for (const QString row:rows) { // for (const QString row:rows) {
rowsData << row.split('\t', QString::SkipEmptyParts); // rowsData << row.split('\t', QString::SkipEmptyParts);
} // }
QTableWidget* table = ui->tableWidget; // QTableWidget* table = ui->tableWidget;
const QModelIndex currentIndex = table->currentIndex(); // const QModelIndex currentIndex = table->currentIndex();
const int startRow = currentIndex.isValid() ? currentIndex.row() : 0; // const int startRow = currentIndex.isValid() ? currentIndex.row() : 0;
const int startCol = currentIndex.isValid() ? currentIndex.column() : 0; // const int startCol = currentIndex.isValid() ? currentIndex.column() : 0;
table->setUpdatesEnabled(false); // table->setUpdatesEnabled(false);
table->setRowCount(std::max(table->rowCount(), startRow + rowsData.size())); // table->setRowCount(std::max(table->rowCount(), startRow + rowsData.size()));
table->setColumnCount(std::max(table->columnCount(), startCol + rowsData[0].size())); // table->setColumnCount(std::max(table->columnCount(), startCol + rowsData[0].size()));
for (int i = 0; i < rowsData.size(); ++i) { // for (int i = 0; i < rowsData.size(); ++i) {
for (int j = 0; j < rowsData[i].size(); ++j) { // for (int j = 0; j < rowsData[i].size(); ++j) {
if (startRow + i >= table->rowCount()) break; // if (startRow + i >= table->rowCount()) break;
if (startCol + j >= table->columnCount()) break; // if (startCol + j >= table->columnCount()) break;
QTableWidgetItem* item = table->item(startRow + i, startCol + j); // QTableWidgetItem* item = table->item(startRow + i, startCol + j);
if (!item) { // if (!item) {
item = new QTableWidgetItem(); // item = new QTableWidgetItem();
table->setItem(startRow + i, startCol + j, item); // table->setItem(startRow + i, startCol + j, item);
} // }
item->setText(rowsData[i][j]); // item->setText(rowsData[i][j]);
} // }
} // }
table->setUpdatesEnabled(true); // table->setUpdatesEnabled(true);
} }
@ -1155,7 +1254,7 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo)
QJsonValue value = lineObjInfo.value("SlfName"); QJsonValue value = lineObjInfo.value("SlfName");
if (value.isString()) { if (value.isString()) {
strSlfName = value.toString(); strSlfName = value.toString();
qDebug() << "SlfName:" << strSlfName; //qDebug() << "SlfName:" << strSlfName;
} }
} }
if (lineObjInfo.contains("WellName")) if (lineObjInfo.contains("WellName"))
@ -1163,7 +1262,7 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo)
QJsonValue value = lineObjInfo.value("WellName"); QJsonValue value = lineObjInfo.value("WellName");
if (value.isString()) { if (value.isString()) {
strWellName = value.toString(); strWellName = value.toString();
qDebug() << "WellName:" << strWellName; //qDebug() << "WellName:" << strWellName;
} }
} }
if (lineObjInfo.contains("TrackName")) if (lineObjInfo.contains("TrackName"))
@ -1171,7 +1270,7 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo)
QJsonValue value = lineObjInfo.value("TrackName"); QJsonValue value = lineObjInfo.value("TrackName");
if (value.isString()) { if (value.isString()) {
strTrackName = value.toString(); strTrackName = value.toString();
qDebug() << "TrackName:" << strTrackName; //qDebug() << "TrackName:" << strTrackName;
} }
} }
if (lineObjInfo.contains("LineName")) if (lineObjInfo.contains("LineName"))
@ -1179,7 +1278,7 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo)
QJsonValue value = lineObjInfo.value("LineName"); QJsonValue value = lineObjInfo.value("LineName");
if (value.isString()) { if (value.isString()) {
strLineName = value.toString(); strLineName = value.toString();
qDebug() << "LineName:" << strLineName; //qDebug() << "LineName:" << strLineName;
} }
} }
@ -1188,7 +1287,7 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo)
QJsonValue value = lineObjInfo.value("vmin"); QJsonValue value = lineObjInfo.value("vmin");
if (value.isDouble()) { if (value.isDouble()) {
newLeftScale = value.toDouble(); newLeftScale = value.toDouble();
qDebug() << "vmin:" << QString::number(newLeftScale); //qDebug() << "vmin:" << QString::number(newLeftScale);
} }
} }
if (lineObjInfo.contains("vmax")) if (lineObjInfo.contains("vmax"))
@ -1196,7 +1295,7 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo)
QJsonValue value = lineObjInfo.value("vmax"); QJsonValue value = lineObjInfo.value("vmax");
if (value.isDouble()) { if (value.isDouble()) {
newRightScale = value.toDouble(); newRightScale = value.toDouble();
qDebug() << "vmax:" << QString::number(newRightScale); //qDebug() << "vmax:" << QString::number(newRightScale);
} }
} }
if (lineObjInfo.contains("ScaleType")) if (lineObjInfo.contains("ScaleType"))
@ -1204,7 +1303,7 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo)
QJsonValue value = lineObjInfo.value("ScaleType"); QJsonValue value = lineObjInfo.value("ScaleType");
if (value.isString()) { if (value.isString()) {
strScaleType = value.toString(); strScaleType = value.toString();
qDebug() << "ScaleType:" << strScaleType; //qDebug() << "ScaleType:" << strScaleType;
} }
} }
if (lineObjInfo.contains("Width")) if (lineObjInfo.contains("Width"))
@ -1212,7 +1311,7 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo)
QJsonValue value = lineObjInfo.value("Width"); QJsonValue value = lineObjInfo.value("Width");
if (value.isDouble()) { if (value.isDouble()) {
width = value.toDouble(); width = value.toDouble();
qDebug() << "Width:" << QString::number(width); //qDebug() << "Width:" << QString::number(width);
} }
} }
@ -1221,7 +1320,7 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo)
QJsonValue value = lineObjInfo.value("lineStyle"); QJsonValue value = lineObjInfo.value("lineStyle");
if (value.isDouble()) { if (value.isDouble()) {
lineStyle = (Qt::PenStyle)value.toInt(); lineStyle = (Qt::PenStyle)value.toInt();
qDebug() << "lineStyle:" << QString::number(lineStyle); //qDebug() << "lineStyle:" << QString::number(lineStyle);
} }
} }
// //
@ -1230,7 +1329,7 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo)
QJsonValue value = lineObjInfo.value("lineColorRed"); QJsonValue value = lineObjInfo.value("lineColorRed");
if (value.isDouble()) { if (value.isDouble()) {
lineColor.setRed(value.toInt()); lineColor.setRed(value.toInt());
qDebug() << "lineColorRed:" << QString::number(value.toInt()); //qDebug() << "lineColorRed:" << QString::number(value.toInt());
} }
} }
// //
@ -1239,7 +1338,7 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo)
QJsonValue value = lineObjInfo.value("lineColorGreen"); QJsonValue value = lineObjInfo.value("lineColorGreen");
if (value.isDouble()) { if (value.isDouble()) {
lineColor.setGreen(value.toInt()); lineColor.setGreen(value.toInt());
qDebug() << "lineColorGreen:" << QString::number(value.toInt()); //qDebug() << "lineColorGreen:" << QString::number(value.toInt());
} }
} }
// //
@ -1248,7 +1347,7 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo)
QJsonValue value = lineObjInfo.value("lineColorBlue"); QJsonValue value = lineObjInfo.value("lineColorBlue");
if (value.isDouble()) { if (value.isDouble()) {
lineColor.setBlue(value.toInt()); lineColor.setBlue(value.toInt());
qDebug() << "lineColorBlue:" << QString::number(value.toInt()); //qDebug() << "lineColorBlue:" << QString::number(value.toInt());
} }
} }
// //
@ -1257,7 +1356,7 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo)
QJsonValue value = lineObjInfo.value("lineColorAlpha"); QJsonValue value = lineObjInfo.value("lineColorAlpha");
if (value.isDouble()) { if (value.isDouble()) {
lineColor.setAlpha(value.toInt()); lineColor.setAlpha(value.toInt());
qDebug() << "lineColorAlpha:" << QString::number(value.toInt()); //qDebug() << "lineColorAlpha:" << QString::number(value.toInt());
} }
} }
@ -1274,7 +1373,7 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo)
QJsonValue value = lineObjInfo.value("newHeadFill"); QJsonValue value = lineObjInfo.value("newHeadFill");
if (value.isString()) { if (value.isString()) {
newHeadFill = value.toString(); newHeadFill = value.toString();
qDebug() << "newHeadFill:" << newHeadFill; //qDebug() << "newHeadFill:" << newHeadFill;
} }
} }
if (lineObjInfo.contains("newTargetLine")) if (lineObjInfo.contains("newTargetLine"))
@ -1282,7 +1381,7 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo)
QJsonValue value = lineObjInfo.value("newTargetLine"); QJsonValue value = lineObjInfo.value("newTargetLine");
if (value.isString()) { if (value.isString()) {
newTargetLine = value.toString(); newTargetLine = value.toString();
qDebug() << "newTargetLine:" << newTargetLine; //qDebug() << "newTargetLine:" << newTargetLine;
} }
} }
if (lineObjInfo.contains("newFillType")) if (lineObjInfo.contains("newFillType"))
@ -1290,7 +1389,7 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo)
QJsonValue value = lineObjInfo.value("newFillType"); QJsonValue value = lineObjInfo.value("newFillType");
if (value.isString()) { if (value.isString()) {
newFillType = value.toString(); newFillType = value.toString();
qDebug() << "newFillType:" << newFillType; //qDebug() << "newFillType:" << newFillType;
} }
} }
if (lineObjInfo.contains("newFillMode")) if (lineObjInfo.contains("newFillMode"))
@ -1298,7 +1397,7 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo)
QJsonValue value = lineObjInfo.value("newFillMode"); QJsonValue value = lineObjInfo.value("newFillMode");
if (value.isString()) { if (value.isString()) {
newFillMode = value.toString(); newFillMode = value.toString();
qDebug() << "newFillMode:" << newFillMode; //qDebug() << "newFillMode:" << newFillMode;
} }
} }
// //
@ -1307,7 +1406,7 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo)
QJsonValue value = lineObjInfo.value("newColorRed"); QJsonValue value = lineObjInfo.value("newColorRed");
if (value.isDouble()) { if (value.isDouble()) {
newColor.setRed(value.toInt()); newColor.setRed(value.toInt());
qDebug() << "newColorRed:" << QString::number(value.toInt()); //qDebug() << "newColorRed:" << QString::number(value.toInt());
} }
} }
// //
@ -1316,7 +1415,7 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo)
QJsonValue value = lineObjInfo.value("newColorGreen"); QJsonValue value = lineObjInfo.value("newColorGreen");
if (value.isDouble()) { if (value.isDouble()) {
newColor.setGreen(value.toInt()); newColor.setGreen(value.toInt());
qDebug() << "newColorGreen:" << QString::number(value.toInt()); //qDebug() << "newColorGreen:" << QString::number(value.toInt());
} }
} }
// //
@ -1325,7 +1424,7 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo)
QJsonValue value = lineObjInfo.value("newColorBlue"); QJsonValue value = lineObjInfo.value("newColorBlue");
if (value.isDouble()) { if (value.isDouble()) {
newColor.setBlue(value.toInt()); newColor.setBlue(value.toInt());
qDebug() << "newColorBlue:" << QString::number(value.toInt()); //qDebug() << "newColorBlue:" << QString::number(value.toInt());
} }
} }
// //
@ -1334,7 +1433,7 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo)
QJsonValue value = lineObjInfo.value("newColorAlpha"); QJsonValue value = lineObjInfo.value("newColorAlpha");
if (value.isDouble()) { if (value.isDouble()) {
newColor.setAlpha(value.toInt()); newColor.setAlpha(value.toInt());
qDebug() << "newColorAlpha:" << QString::number(value.toInt()); //qDebug() << "newColorAlpha:" << QString::number(value.toInt());
} }
} }
@ -1343,7 +1442,7 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo)
QJsonValue value = lineObjInfo.value("newLithosImage"); QJsonValue value = lineObjInfo.value("newLithosImage");
if (value.isString()) { if (value.isString()) {
newLithosImage = value.toString(); newLithosImage = value.toString();
qDebug() << "newLithosImage:" << newLithosImage; //qDebug() << "newLithosImage:" << newLithosImage;
} }
} }
if (lineObjInfo.contains("new_vMin")) if (lineObjInfo.contains("new_vMin"))
@ -1351,7 +1450,7 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo)
QJsonValue value = lineObjInfo.value("new_vMin"); QJsonValue value = lineObjInfo.value("new_vMin");
if (value.isDouble()) { if (value.isDouble()) {
new_vMin = value.toDouble(); new_vMin = value.toDouble();
qDebug() << "new_vMin:" << QString::number(new_vMin); //qDebug() << "new_vMin:" << QString::number(new_vMin);
} }
} }
if (lineObjInfo.contains("new_vMax")) if (lineObjInfo.contains("new_vMax"))
@ -1359,7 +1458,7 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo)
QJsonValue value = lineObjInfo.value("new_vMax"); QJsonValue value = lineObjInfo.value("new_vMax");
if (value.isDouble()) { if (value.isDouble()) {
new_vMax = value.toDouble(); new_vMax = value.toDouble();
qDebug() << "new_vMax:" << QString::number(new_vMax); //qDebug() << "new_vMax:" << QString::number(new_vMax);
} }
} }
// //
@ -1368,7 +1467,7 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo)
QJsonValue value = lineObjInfo.value("frontColorRed"); QJsonValue value = lineObjInfo.value("frontColorRed");
if (value.isDouble()) { if (value.isDouble()) {
frontColor.setRed(value.toInt()); frontColor.setRed(value.toInt());
qDebug() << "frontColorRed:" << QString::number(value.toInt()); //qDebug() << "frontColorRed:" << QString::number(value.toInt());
} }
} }
// //
@ -1377,7 +1476,7 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo)
QJsonValue value = lineObjInfo.value("frontColorGreen"); QJsonValue value = lineObjInfo.value("frontColorGreen");
if (value.isDouble()) { if (value.isDouble()) {
frontColor.setGreen(value.toInt()); frontColor.setGreen(value.toInt());
qDebug() << "frontColorGreen:" << QString::number(value.toInt()); //qDebug() << "frontColorGreen:" << QString::number(value.toInt());
} }
} }
// //
@ -1386,7 +1485,7 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo)
QJsonValue value = lineObjInfo.value("frontColorBlue"); QJsonValue value = lineObjInfo.value("frontColorBlue");
if (value.isDouble()) { if (value.isDouble()) {
frontColor.setBlue(value.toInt()); frontColor.setBlue(value.toInt());
qDebug() << "frontColorBlue:" << QString::number(value.toInt()); //qDebug() << "frontColorBlue:" << QString::number(value.toInt());
} }
} }
// //
@ -1395,7 +1494,7 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo)
QJsonValue value = lineObjInfo.value("frontColorAlpha"); QJsonValue value = lineObjInfo.value("frontColorAlpha");
if (value.isDouble()) { if (value.isDouble()) {
frontColor.setAlpha(value.toInt()); frontColor.setAlpha(value.toInt());
qDebug() << "frontColorAlpha:" << QString::number(value.toInt()); //qDebug() << "frontColorAlpha:" << QString::number(value.toInt());
} }
} }
// //
@ -1404,7 +1503,7 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo)
QJsonValue value = lineObjInfo.value("backColorRed"); QJsonValue value = lineObjInfo.value("backColorRed");
if (value.isDouble()) { if (value.isDouble()) {
backColor.setRed(value.toInt()); backColor.setRed(value.toInt());
qDebug() << "backColorRed:" << QString::number(value.toInt()); //qDebug() << "backColorRed:" << QString::number(value.toInt());
} }
} }
// //
@ -1413,7 +1512,7 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo)
QJsonValue value = lineObjInfo.value("backColorGreen"); QJsonValue value = lineObjInfo.value("backColorGreen");
if (value.isDouble()) { if (value.isDouble()) {
backColor.setGreen(value.toInt()); backColor.setGreen(value.toInt());
qDebug() << "backColorGreen:" << QString::number(value.toInt()); //qDebug() << "backColorGreen:" << QString::number(value.toInt());
} }
} }
// //
@ -1422,7 +1521,7 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo)
QJsonValue value = lineObjInfo.value("backColorBlue"); QJsonValue value = lineObjInfo.value("backColorBlue");
if (value.isDouble()) { if (value.isDouble()) {
backColor.setBlue(value.toInt()); backColor.setBlue(value.toInt());
qDebug() << "backColorBlue:" << QString::number(value.toInt()); //qDebug() << "backColorBlue:" << QString::number(value.toInt());
} }
} }
// //
@ -1431,7 +1530,7 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo)
QJsonValue value = lineObjInfo.value("backColorAlpha"); QJsonValue value = lineObjInfo.value("backColorAlpha");
if (value.isDouble()) { if (value.isDouble()) {
backColor.setAlpha(value.toInt()); backColor.setAlpha(value.toInt());
qDebug() << "backColorAlpha:" << QString::number(value.toInt()); //qDebug() << "backColorAlpha:" << QString::number(value.toInt());
} }
} }

View File

@ -15,15 +15,11 @@
</property> </property>
<widget class="QWidget" name="centralwidget"> <widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="1"> <item row="1" column="1">
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0">
<item> <item>
<widget class="QTableWidget" name="tableWidget"/> <widget class="QTableWidget" name="tableWidget"/>
</item> </item>
</layout>
</item>
<item> <item>
<widget class="QTableWidget" name="tableWidget_2"/> <widget class="QTableWidget" name="tableWidget_2"/>
</item> </item>

View File

@ -881,6 +881,7 @@ void QMyCustomPlot::s_ChangeFillMode(QString strUuid, QString strSlfName, QStrin
graph(0)->setChannelFillGraph( this->graph(1)); graph(0)->setChannelFillGraph( this->graph(1));
// //
replot(); replot();
//update();
} }
} }