支持添加多个图头表格
This commit is contained in:
parent
d908a3a84a
commit
298e0b1cf1
|
|
@ -546,7 +546,7 @@ void FormDraw::initForm(QMyCustomPlot *widget, QString strSlfName, QString strLi
|
|||
widget->m_iY2 = g_iY2;
|
||||
//
|
||||
widget->xAxis->setRange(vmin, vmax);
|
||||
widget->yAxis->setRange(g_iY1, g_iY2);
|
||||
widget->yAxis->setRange(g_iY1, g_iY2);
|
||||
widget->axisRect()->setupFullAxesBox();
|
||||
//
|
||||
widget->xAxis->ticker()->setTickCount(10);//x个主刻度
|
||||
|
|
@ -629,22 +629,15 @@ void FormDraw::addRandomGraph(QMyCustomPlot *widget, QVector<double> x, QVector<
|
|||
else
|
||||
{
|
||||
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(QPixmap(":/image/file.png")));
|
||||
|
||||
//widget->graph()->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssDisc, 5));
|
||||
|
||||
QPen graphPen;
|
||||
newlineColor = QColor(std::rand()%245+10, std::rand()%245+10, std::rand()%245+10);
|
||||
graphPen.setColor(newlineColor);
|
||||
//graphPen.setWidthF(std::rand()/(double)RAND_MAX*2+1);
|
||||
width = 2;
|
||||
graphPen.setWidthF(width);
|
||||
graphPen.setStyle(Qt::SolidLine);//实线
|
||||
|
|
|
|||
|
|
@ -3,8 +3,15 @@
|
|||
#include <QMessageBox>
|
||||
#include <QMenu>
|
||||
#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) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::FormHead)
|
||||
|
|
@ -13,13 +20,21 @@ FormHead::FormHead(QWidget *parent, int 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);
|
||||
|
||||
// 连接信号和槽
|
||||
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()
|
||||
|
|
@ -27,80 +42,56 @@ FormHead::~FormHead()
|
|||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
void FormHead::Init()
|
||||
void FormHead::resizeWindow()
|
||||
{
|
||||
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->verticalHeader()->hide();//隐藏左侧系统序号栏
|
||||
ui->tableWidget->horizontalHeader()->hide();//隐藏上方系统序号栏
|
||||
//ui->tableWidget->verticalHeader()->setFixedWidth(3);//标题栏宽度
|
||||
//ui->tableWidget->horizontalHeader()->setFixedHeight(3);//标题栏高度
|
||||
|
||||
//QRect rect = this->rect();
|
||||
|
||||
//因为tableWidget需要提前规定好行数与列数
|
||||
int recordcount = 0; //总行数
|
||||
ui->tableWidget->setColumnCount(1);
|
||||
ui->tableWidget->setRowCount(recordcount); //动态设置行数
|
||||
ui->tableWidget->setColumnCount(m_iCols);//列数
|
||||
ui->tableWidget->setRowCount(m_iRows); //动态设置行数
|
||||
|
||||
//设置所有列均匀分布并填充满整个空间
|
||||
QHeaderView *header = ui->tableWidget->horizontalHeader();
|
||||
for (int i = 0; i < ui->tableWidget->columnCount(); ++i) {
|
||||
header->setSectionResizeMode(i, QHeaderView::Stretch);
|
||||
for(int i=0; i<m_iRows; i++)
|
||||
{
|
||||
//设置高度
|
||||
ui->tableWidget->setRowHeight(i, g_iRowsHight);
|
||||
|
||||
for(int j=0; j<m_iCols; j++)
|
||||
{
|
||||
//设置列宽
|
||||
ui->tableWidget->setColumnWidth(j, g_iColsWidth);
|
||||
|
||||
QTableWidgetItem* item = new QTableWidgetItem("");
|
||||
ui->tableWidget->setItem(i, j, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FormHead::Add(QString strLineName, QColor lineColor)
|
||||
{
|
||||
int row = ui->tableWidget->rowCount();
|
||||
ui->tableWidget->setRowCount(row + 1);
|
||||
|
||||
QFont font("微软雅黑", 12, QFont::Bold, false);
|
||||
//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 的位置信息
|
||||
//int row = item->row();
|
||||
//int column = item->column();
|
||||
// 处理 item 点击的逻辑
|
||||
//qDebug() << "Item at row" << row << "column" << column << "clicked.";
|
||||
|
||||
QString message = "选中项: " + item->text();
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,18 +23,17 @@ private:
|
|||
|
||||
public:
|
||||
int m_indexID;
|
||||
int m_iRows;
|
||||
int m_iCols;
|
||||
QTimer *m_timer;
|
||||
|
||||
public:
|
||||
void Init();
|
||||
void Add(QString strLineName, QColor lineColor);
|
||||
void Init(int iRows, int iCols, int iWidth);
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
|
||||
public slots:
|
||||
void onItemClicked(QTableWidgetItem *item);
|
||||
void s_AddLine();
|
||||
void s_DelOne();
|
||||
void resizeWindow();
|
||||
|
||||
private slots:
|
||||
void on_tableWidget_customContextMenuRequested(const QPoint &pos);
|
||||
};
|
||||
|
||||
#endif // FORMHEAD_H
|
||||
|
|
|
|||
|
|
@ -14,51 +14,16 @@
|
|||
<string>Form</string>
|
||||
</property>
|
||||
<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">
|
||||
<widget class="QTableWidget" name="tableWidget">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QTableCornerButton::section
|
||||
{
|
||||
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>
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ SOURCES += \
|
|||
customtabwidget.cpp \
|
||||
fileedit.cpp \
|
||||
formdraw.cpp \
|
||||
formhead.cpp \
|
||||
forminfo.cpp \
|
||||
formline.cpp \
|
||||
formtrack.cpp \
|
||||
|
|
@ -68,6 +69,7 @@ HEADERS += \
|
|||
customtabwidget.h \
|
||||
fileedit.h \
|
||||
formdraw.h \
|
||||
formhead.h \
|
||||
forminfo.h \
|
||||
formline.h \
|
||||
formtrack.h \
|
||||
|
|
@ -91,15 +93,12 @@ FORMS += \
|
|||
formhead.ui \
|
||||
forminfo.ui \
|
||||
formline.ui \
|
||||
formtitle.ui \
|
||||
formtrack.ui \
|
||||
formwell.ui \
|
||||
interfaceWidget.ui \
|
||||
mainwindow.ui \
|
||||
mainwindowcurve.ui \
|
||||
mainwindownew.ui \
|
||||
newheaddialog.ui \
|
||||
qtcenterwidgets.ui \
|
||||
qtprojectwidgets.ui
|
||||
|
||||
INCLUDEPATH += ../include/ \
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ int g_iY1 = -3000;
|
|||
int g_iY2 = 0;
|
||||
int g_iCanZoom = 0;
|
||||
|
||||
int g_iScale = 1000;
|
||||
int g_iScale = 3000;
|
||||
QString g_prjname="";
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
#include <QFuture>
|
||||
#include <QtConcurrent/QtConcurrent>
|
||||
#include "newheaddialog.h"
|
||||
#include "formhead.h"
|
||||
#include "qmytablewidget.h"
|
||||
|
||||
extern int g_iOneWidth; //道宽
|
||||
extern QString g_prjname;
|
||||
|
|
@ -19,6 +21,8 @@ extern int g_iScale;
|
|||
|
||||
extern int g_iRows;
|
||||
extern int g_iCols;
|
||||
extern int g_iColsWidth;
|
||||
extern int g_iRowsHight;
|
||||
|
||||
MainWindowCurve::MainWindowCurve(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
|
|
@ -41,9 +45,26 @@ MainWindowCurve::MainWindowCurve(QWidget *parent) :
|
|||
|
||||
//-------------------------------------
|
||||
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->horizontalHeader()->hide();
|
||||
ui->tableWidget->verticalHeader()->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);
|
||||
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->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||
|
||||
// //表头
|
||||
// QStringList list;
|
||||
// list << "" << "" << "" << "";
|
||||
|
|
@ -280,6 +302,30 @@ void MainWindowCurve::s_showHeadTable()
|
|||
else {
|
||||
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()
|
||||
|
|
@ -555,295 +601,348 @@ void MainWindowCurve::dropEvent(QDropEvent* event)
|
|||
//QApplication::restoreOverrideCursor();
|
||||
}
|
||||
|
||||
|
||||
void MainWindowCurve::slotContextMenu(QPoint pos)
|
||||
{
|
||||
if(ui->tableWidget->rowCount()==0 && ui->tableWidget->rowCount()==0)
|
||||
{
|
||||
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++)
|
||||
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=";
|
||||
|
||||
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)//列宽变大
|
||||
{
|
||||
for(int j=0; j<g_iCols; j++)
|
||||
{
|
||||
QTableWidgetItem* item = new QTableWidgetItem("");
|
||||
ui->tableWidget->setItem(i, j, item);
|
||||
}
|
||||
iWidth=g_iCols*g_iColsWidth;
|
||||
//设置列宽
|
||||
ui->tableWidget->setColumnWidth(0, g_iCols*(g_iColsWidth+1)+1);
|
||||
}
|
||||
|
||||
}
|
||||
else if (result == QDialog::Rejected) {
|
||||
// 处理用户点击了取消按钮的逻辑
|
||||
qDebug() << "Rejected=";
|
||||
}
|
||||
else {
|
||||
// 处理其他情况的逻辑
|
||||
qDebug() << "other=";
|
||||
}
|
||||
//
|
||||
FormHead *widgetHead = new FormHead(this, 1);
|
||||
widgetHead->Init(g_iRows, g_iCols, iWidth);
|
||||
ui->tableWidget->setCellWidget(rowcount, 0, widgetHead);
|
||||
}
|
||||
else if (result == QDialog::Rejected) {
|
||||
// 处理用户点击了取消按钮的逻辑
|
||||
qDebug() << "Rejected=";
|
||||
}
|
||||
else {
|
||||
// 处理其他情况的逻辑
|
||||
qDebug() << "other=";
|
||||
}
|
||||
}
|
||||
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(ui->tableWidget->rowCount()==0 && ui->tableWidget->rowCount()==0)
|
||||
// {
|
||||
// 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() << "合并表格";
|
||||
slotMerge();
|
||||
} else if (selectedAction == deleteAction) {
|
||||
//删除1行
|
||||
int row = ui->tableWidget->currentRow();
|
||||
ui->tableWidget->removeRow(row);
|
||||
} else if (selectedAction == refreshAction) {
|
||||
qDebug() << "拆分表格";
|
||||
slotSplit();
|
||||
}
|
||||
}
|
||||
// }
|
||||
// else if (result == QDialog::Rejected) {
|
||||
// // 处理用户点击了取消按钮的逻辑
|
||||
// qDebug() << "Rejected=";
|
||||
// }
|
||||
// else {
|
||||
// // 处理其他情况的逻辑
|
||||
// qDebug() << "other=";
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// 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()
|
||||
{
|
||||
QModelIndexList list = ui->tableWidget->selectionModel()->selectedIndexes();
|
||||
if (list.size() < 2)
|
||||
{
|
||||
QMessageBox::warning(this, "单元格合并", "所选中单元格中为单个单元格,无法合并", "确定");
|
||||
return;
|
||||
}
|
||||
// QModelIndexList list = ui->tableWidget->selectionModel()->selectedIndexes();
|
||||
// if (list.size() < 2)
|
||||
// {
|
||||
// QMessageBox::warning(this, "单元格合并", "所选中单元格中为单个单元格,无法合并", "确定");
|
||||
// return;
|
||||
// }
|
||||
|
||||
int topRow = 0;
|
||||
int leftCol = 0;
|
||||
int bottomRow = 0;
|
||||
int rightCol = 0;
|
||||
// int topRow = 0;
|
||||
// int leftCol = 0;
|
||||
// int bottomRow = 0;
|
||||
// int rightCol = 0;
|
||||
|
||||
QList<QTableWidgetSelectionRange> selectRanges = ui->tableWidget->selectedRanges();
|
||||
// QList<QTableWidgetSelectionRange> selectRanges = ui->tableWidget->selectedRanges();
|
||||
|
||||
if (selectRanges.size() > 0)
|
||||
{
|
||||
topRow = selectRanges[0].topRow();
|
||||
leftCol = selectRanges[0].leftColumn();
|
||||
bottomRow = selectRanges[0].bottomRow();
|
||||
rightCol = selectRanges[0].rightColumn();
|
||||
}
|
||||
for(auto range:selectRanges)
|
||||
{
|
||||
if(range.topRow()<topRow)
|
||||
topRow=range.topRow();
|
||||
if(range.leftColumn()<leftCol)
|
||||
leftCol=range.leftColumn();
|
||||
if(range.bottomRow()> bottomRow)
|
||||
bottomRow=range.bottomRow();
|
||||
if(range.rightColumn()>rightCol)
|
||||
rightCol=range.rightColumn();
|
||||
}
|
||||
// if (selectRanges.size() > 0)
|
||||
// {
|
||||
// topRow = selectRanges[0].topRow();
|
||||
// leftCol = selectRanges[0].leftColumn();
|
||||
// bottomRow = selectRanges[0].bottomRow();
|
||||
// rightCol = selectRanges[0].rightColumn();
|
||||
// }
|
||||
// for(auto range:selectRanges)
|
||||
// {
|
||||
// if(range.topRow()<topRow)
|
||||
// topRow=range.topRow();
|
||||
// if(range.leftColumn()<leftCol)
|
||||
// leftCol=range.leftColumn();
|
||||
// if(range.bottomRow()> bottomRow)
|
||||
// bottomRow=range.bottomRow();
|
||||
// if(range.rightColumn()>rightCol)
|
||||
// rightCol=range.rightColumn();
|
||||
// }
|
||||
|
||||
int rowSpan = (bottomRow - topRow) + 1;
|
||||
int colSpan = (rightCol - leftCol) + 1;
|
||||
ui->tableWidget->setSpan(topRow, leftCol, rowSpan, colSpan);
|
||||
// int rowSpan = (bottomRow - topRow) + 1;
|
||||
// int colSpan = (rightCol - leftCol) + 1;
|
||||
// ui->tableWidget->setSpan(topRow, leftCol, rowSpan, colSpan);
|
||||
}
|
||||
|
||||
|
||||
//拆分
|
||||
void MainWindowCurve::slotSplit()
|
||||
{
|
||||
int row,col;
|
||||
QList<QTableWidgetSelectionRange> selectRanges = ui->tableWidget->selectedRanges();
|
||||
if (selectRanges.size() < 2)
|
||||
{
|
||||
QMessageBox::warning(this, "拆分表格失败", "单元格已是最小单位,不能再进行拆分", "确定");
|
||||
return;
|
||||
}
|
||||
QList<QTableWidgetItem*> selectItems = ui->tableWidget->selectedItems();
|
||||
if(selectItems.size()==0)
|
||||
{
|
||||
QMessageBox::warning(this, "拆分表格失败", "请先为表格设置元素item", "确定");
|
||||
return;
|
||||
}
|
||||
if(selectItems.size()>1)
|
||||
{
|
||||
QMessageBox::warning(this, "拆分表格失败", "非法选择", "确定");
|
||||
return;
|
||||
}
|
||||
for(auto item:selectItems)
|
||||
{
|
||||
row= item->row();
|
||||
col=item->column();
|
||||
}
|
||||
// int row,col;
|
||||
// QList<QTableWidgetSelectionRange> selectRanges = ui->tableWidget->selectedRanges();
|
||||
// if (selectRanges.size() < 2)
|
||||
// {
|
||||
// QMessageBox::warning(this, "拆分表格失败", "单元格已是最小单位,不能再进行拆分", "确定");
|
||||
// return;
|
||||
// }
|
||||
// QList<QTableWidgetItem*> selectItems = ui->tableWidget->selectedItems();
|
||||
// if(selectItems.size()==0)
|
||||
// {
|
||||
// QMessageBox::warning(this, "拆分表格失败", "请先为表格设置元素item", "确定");
|
||||
// return;
|
||||
// }
|
||||
// if(selectItems.size()>1)
|
||||
// {
|
||||
// QMessageBox::warning(this, "拆分表格失败", "非法选择", "确定");
|
||||
// return;
|
||||
// }
|
||||
// for(auto item:selectItems)
|
||||
// {
|
||||
// row= item->row();
|
||||
// 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)
|
||||
{
|
||||
if (obj == ui->tableWidget && event->type() == QEvent::KeyPress) {
|
||||
QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
|
||||
if (keyEvent->matches(QKeySequence::Paste)) {
|
||||
onPasteExcelData();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// if (obj == ui->tableWidget && event->type() == QEvent::KeyPress) {
|
||||
// QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
|
||||
// if (keyEvent->matches(QKeySequence::Paste)) {
|
||||
// onPasteExcelData();
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
return QMainWindow::eventFilter(obj, event);
|
||||
}
|
||||
|
||||
//复制粘贴事件
|
||||
void MainWindowCurve::keyPressEvent(QKeyEvent * event)
|
||||
{
|
||||
//excel 行分是 "\n" ; 列分是 "\t"
|
||||
if (event->matches(QKeySequence::Copy))
|
||||
{
|
||||
copy();
|
||||
}
|
||||
else if (event->matches(QKeySequence::Paste))
|
||||
{
|
||||
Paste();
|
||||
}
|
||||
else if (event->matches(QKeySequence::SelectAll))
|
||||
{
|
||||
ui->tableWidget->selectAll();
|
||||
}
|
||||
else
|
||||
{
|
||||
QWidget::keyPressEvent(event);
|
||||
}
|
||||
// //excel 行分是 "\n" ; 列分是 "\t"
|
||||
// if (event->matches(QKeySequence::Copy))
|
||||
// {
|
||||
// copy();
|
||||
// }
|
||||
// else if (event->matches(QKeySequence::Paste))
|
||||
// {
|
||||
// Paste();
|
||||
// }
|
||||
// else if (event->matches(QKeySequence::SelectAll))
|
||||
// {
|
||||
// ui->tableWidget->selectAll();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// QWidget::keyPressEvent(event);
|
||||
// }
|
||||
}
|
||||
|
||||
void MainWindowCurve::copy()
|
||||
{
|
||||
QMap<int, QList<int>> selMap;//行,列
|
||||
QList<QTableWidgetItem*> list = ui->tableWidget->selectedItems();
|
||||
if (list.count() <= 0)
|
||||
return;
|
||||
for (QTableWidgetItem* item : list)
|
||||
{
|
||||
int rowN = ui->tableWidget->row(item);
|
||||
int colN = ui->tableWidget->column(item);
|
||||
selMap[rowN].append(colN);
|
||||
}
|
||||
QString cpStr;
|
||||
QMap<int, QList<int>>::iterator it = selMap.begin();
|
||||
while (it != selMap.end())
|
||||
{
|
||||
for (int i = 0; i < (*it).count(); i++)
|
||||
{
|
||||
QTableWidgetItem* item = ui->tableWidget->item(it.key(), (*it).at(i));
|
||||
if (item)
|
||||
{
|
||||
cpStr.append(item->text().trimmed());
|
||||
}
|
||||
if (i != (*it).count() - 1)
|
||||
cpStr.append("\t");
|
||||
}
|
||||
it++;
|
||||
if (it != selMap.end())
|
||||
{
|
||||
cpStr.append("\n");
|
||||
}
|
||||
}
|
||||
QApplication::clipboard()->setText(cpStr);
|
||||
// QMap<int, QList<int>> selMap;//行,列
|
||||
// QList<QTableWidgetItem*> list = ui->tableWidget->selectedItems();
|
||||
// if (list.count() <= 0)
|
||||
// return;
|
||||
// for (QTableWidgetItem* item : list)
|
||||
// {
|
||||
// int rowN = ui->tableWidget->row(item);
|
||||
// int colN = ui->tableWidget->column(item);
|
||||
// selMap[rowN].append(colN);
|
||||
// }
|
||||
// QString cpStr;
|
||||
// QMap<int, QList<int>>::iterator it = selMap.begin();
|
||||
// while (it != selMap.end())
|
||||
// {
|
||||
// for (int i = 0; i < (*it).count(); i++)
|
||||
// {
|
||||
// QTableWidgetItem* item = ui->tableWidget->item(it.key(), (*it).at(i));
|
||||
// if (item)
|
||||
// {
|
||||
// cpStr.append(item->text().trimmed());
|
||||
// }
|
||||
// if (i != (*it).count() - 1)
|
||||
// cpStr.append("\t");
|
||||
// }
|
||||
// it++;
|
||||
// if (it != selMap.end())
|
||||
// {
|
||||
// cpStr.append("\n");
|
||||
// }
|
||||
// }
|
||||
// QApplication::clipboard()->setText(cpStr);
|
||||
}
|
||||
|
||||
void MainWindowCurve::Paste()
|
||||
{
|
||||
QString pastText = QApplication::clipboard()->text();
|
||||
QStringList rowList = pastText.split("\n", QString::KeepEmptyParts);
|
||||
if(rowList.size()==0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(rowList.at(rowList.size()-1)=="")
|
||||
{
|
||||
rowList.removeAt(rowList.size()-1);
|
||||
}
|
||||
QTableWidgetItem* crtItem = ui->tableWidget->currentItem();
|
||||
int rowN, colN;
|
||||
if (!crtItem)
|
||||
{
|
||||
rowN = ui->tableWidget->currentRow();
|
||||
colN = ui->tableWidget->currentColumn();
|
||||
}
|
||||
else
|
||||
{
|
||||
rowN = ui->tableWidget->row(crtItem);
|
||||
colN = ui->tableWidget->column(crtItem);
|
||||
}
|
||||
for (int i = 0; i < (ui->tableWidget->rowCount() - rowN) && (i < rowList.length()); i++)
|
||||
{
|
||||
QStringList rowDataList = rowList.at(i).split("\t", QString::KeepEmptyParts);
|
||||
for (int j = 0; j < (ui->tableWidget->columnCount() - colN) && (j < rowDataList.length()); j++)
|
||||
{
|
||||
int x = i + rowN;
|
||||
int y = j + colN;
|
||||
// QString pastText = QApplication::clipboard()->text();
|
||||
// QStringList rowList = pastText.split("\n", QString::KeepEmptyParts);
|
||||
// if(rowList.size()==0)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
// if(rowList.at(rowList.size()-1)=="")
|
||||
// {
|
||||
// rowList.removeAt(rowList.size()-1);
|
||||
// }
|
||||
// QTableWidgetItem* crtItem = ui->tableWidget->currentItem();
|
||||
// int rowN, colN;
|
||||
// if (!crtItem)
|
||||
// {
|
||||
// rowN = ui->tableWidget->currentRow();
|
||||
// colN = ui->tableWidget->currentColumn();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// rowN = ui->tableWidget->row(crtItem);
|
||||
// colN = ui->tableWidget->column(crtItem);
|
||||
// }
|
||||
// for (int i = 0; i < (ui->tableWidget->rowCount() - rowN) && (i < rowList.length()); i++)
|
||||
// {
|
||||
// QStringList rowDataList = rowList.at(i).split("\t", QString::KeepEmptyParts);
|
||||
// for (int j = 0; j < (ui->tableWidget->columnCount() - colN) && (j < rowDataList.length()); j++)
|
||||
// {
|
||||
// int x = i + rowN;
|
||||
// int y = j + colN;
|
||||
|
||||
QTableWidgetItem* item = ui->tableWidget->item(x, y);
|
||||
if (item)
|
||||
{
|
||||
item->setText(rowDataList.at(j));
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->tableWidget->setItem(x, y, new QTableWidgetItem(rowDataList.at(j)));
|
||||
}
|
||||
}
|
||||
}
|
||||
// QTableWidgetItem* item = ui->tableWidget->item(x, y);
|
||||
// if (item)
|
||||
// {
|
||||
// item->setText(rowDataList.at(j));
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// ui->tableWidget->setItem(x, y, new QTableWidgetItem(rowDataList.at(j)));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
void MainWindowCurve::onPasteExcelData()
|
||||
{
|
||||
QClipboard* clipboard = QApplication::clipboard();
|
||||
const QString clipData = clipboard->text();
|
||||
// QClipboard* clipboard = QApplication::clipboard();
|
||||
// const QString clipData = clipboard->text();
|
||||
|
||||
if (clipData.isEmpty()) return;
|
||||
// if (clipData.isEmpty()) return;
|
||||
|
||||
QList<QStringList> rowsData;
|
||||
const QStringList rows = clipData.split('\n', QString::SkipEmptyParts);
|
||||
for (const QString row:rows) {
|
||||
rowsData << row.split('\t', QString::SkipEmptyParts);
|
||||
}
|
||||
// QList<QStringList> rowsData;
|
||||
// const QStringList rows = clipData.split('\n', QString::SkipEmptyParts);
|
||||
// for (const QString row:rows) {
|
||||
// rowsData << row.split('\t', QString::SkipEmptyParts);
|
||||
// }
|
||||
|
||||
QTableWidget* table = ui->tableWidget;
|
||||
const QModelIndex currentIndex = table->currentIndex();
|
||||
const int startRow = currentIndex.isValid() ? currentIndex.row() : 0;
|
||||
const int startCol = currentIndex.isValid() ? currentIndex.column() : 0;
|
||||
// QTableWidget* table = ui->tableWidget;
|
||||
// const QModelIndex currentIndex = table->currentIndex();
|
||||
// const int startRow = currentIndex.isValid() ? currentIndex.row() : 0;
|
||||
// const int startCol = currentIndex.isValid() ? currentIndex.column() : 0;
|
||||
|
||||
table->setUpdatesEnabled(false);
|
||||
table->setRowCount(std::max(table->rowCount(), startRow + rowsData.size()));
|
||||
table->setColumnCount(std::max(table->columnCount(), startCol + rowsData[0].size()));
|
||||
// table->setUpdatesEnabled(false);
|
||||
// table->setRowCount(std::max(table->rowCount(), startRow + rowsData.size()));
|
||||
// table->setColumnCount(std::max(table->columnCount(), startCol + rowsData[0].size()));
|
||||
|
||||
for (int i = 0; i < rowsData.size(); ++i) {
|
||||
for (int j = 0; j < rowsData[i].size(); ++j) {
|
||||
if (startRow + i >= table->rowCount()) break;
|
||||
if (startCol + j >= table->columnCount()) break;
|
||||
// for (int i = 0; i < rowsData.size(); ++i) {
|
||||
// for (int j = 0; j < rowsData[i].size(); ++j) {
|
||||
// if (startRow + i >= table->rowCount()) break;
|
||||
// if (startCol + j >= table->columnCount()) break;
|
||||
|
||||
QTableWidgetItem* item = table->item(startRow + i, startCol + j);
|
||||
if (!item) {
|
||||
item = new QTableWidgetItem();
|
||||
table->setItem(startRow + i, startCol + j, item);
|
||||
}
|
||||
item->setText(rowsData[i][j]);
|
||||
}
|
||||
}
|
||||
table->setUpdatesEnabled(true);
|
||||
// QTableWidgetItem* item = table->item(startRow + i, startCol + j);
|
||||
// if (!item) {
|
||||
// item = new QTableWidgetItem();
|
||||
// table->setItem(startRow + i, startCol + j, item);
|
||||
// }
|
||||
// item->setText(rowsData[i][j]);
|
||||
// }
|
||||
// }
|
||||
// table->setUpdatesEnabled(true);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1155,7 +1254,7 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo)
|
|||
QJsonValue value = lineObjInfo.value("SlfName");
|
||||
if (value.isString()) {
|
||||
strSlfName = value.toString();
|
||||
qDebug() << "SlfName:" << strSlfName;
|
||||
//qDebug() << "SlfName:" << strSlfName;
|
||||
}
|
||||
}
|
||||
if (lineObjInfo.contains("WellName"))
|
||||
|
|
@ -1163,7 +1262,7 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo)
|
|||
QJsonValue value = lineObjInfo.value("WellName");
|
||||
if (value.isString()) {
|
||||
strWellName = value.toString();
|
||||
qDebug() << "WellName:" << strWellName;
|
||||
//qDebug() << "WellName:" << strWellName;
|
||||
}
|
||||
}
|
||||
if (lineObjInfo.contains("TrackName"))
|
||||
|
|
@ -1171,7 +1270,7 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo)
|
|||
QJsonValue value = lineObjInfo.value("TrackName");
|
||||
if (value.isString()) {
|
||||
strTrackName = value.toString();
|
||||
qDebug() << "TrackName:" << strTrackName;
|
||||
//qDebug() << "TrackName:" << strTrackName;
|
||||
}
|
||||
}
|
||||
if (lineObjInfo.contains("LineName"))
|
||||
|
|
@ -1179,7 +1278,7 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo)
|
|||
QJsonValue value = lineObjInfo.value("LineName");
|
||||
if (value.isString()) {
|
||||
strLineName = value.toString();
|
||||
qDebug() << "LineName:" << strLineName;
|
||||
//qDebug() << "LineName:" << strLineName;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1188,7 +1287,7 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo)
|
|||
QJsonValue value = lineObjInfo.value("vmin");
|
||||
if (value.isDouble()) {
|
||||
newLeftScale = value.toDouble();
|
||||
qDebug() << "vmin:" << QString::number(newLeftScale);
|
||||
//qDebug() << "vmin:" << QString::number(newLeftScale);
|
||||
}
|
||||
}
|
||||
if (lineObjInfo.contains("vmax"))
|
||||
|
|
@ -1196,7 +1295,7 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo)
|
|||
QJsonValue value = lineObjInfo.value("vmax");
|
||||
if (value.isDouble()) {
|
||||
newRightScale = value.toDouble();
|
||||
qDebug() << "vmax:" << QString::number(newRightScale);
|
||||
//qDebug() << "vmax:" << QString::number(newRightScale);
|
||||
}
|
||||
}
|
||||
if (lineObjInfo.contains("ScaleType"))
|
||||
|
|
@ -1204,7 +1303,7 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo)
|
|||
QJsonValue value = lineObjInfo.value("ScaleType");
|
||||
if (value.isString()) {
|
||||
strScaleType = value.toString();
|
||||
qDebug() << "ScaleType:" << strScaleType;
|
||||
//qDebug() << "ScaleType:" << strScaleType;
|
||||
}
|
||||
}
|
||||
if (lineObjInfo.contains("Width"))
|
||||
|
|
@ -1212,7 +1311,7 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo)
|
|||
QJsonValue value = lineObjInfo.value("Width");
|
||||
if (value.isDouble()) {
|
||||
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");
|
||||
if (value.isDouble()) {
|
||||
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");
|
||||
if (value.isDouble()) {
|
||||
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");
|
||||
if (value.isDouble()) {
|
||||
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");
|
||||
if (value.isDouble()) {
|
||||
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");
|
||||
if (value.isDouble()) {
|
||||
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");
|
||||
if (value.isString()) {
|
||||
newHeadFill = value.toString();
|
||||
qDebug() << "newHeadFill:" << newHeadFill;
|
||||
//qDebug() << "newHeadFill:" << newHeadFill;
|
||||
}
|
||||
}
|
||||
if (lineObjInfo.contains("newTargetLine"))
|
||||
|
|
@ -1282,7 +1381,7 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo)
|
|||
QJsonValue value = lineObjInfo.value("newTargetLine");
|
||||
if (value.isString()) {
|
||||
newTargetLine = value.toString();
|
||||
qDebug() << "newTargetLine:" << newTargetLine;
|
||||
//qDebug() << "newTargetLine:" << newTargetLine;
|
||||
}
|
||||
}
|
||||
if (lineObjInfo.contains("newFillType"))
|
||||
|
|
@ -1290,7 +1389,7 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo)
|
|||
QJsonValue value = lineObjInfo.value("newFillType");
|
||||
if (value.isString()) {
|
||||
newFillType = value.toString();
|
||||
qDebug() << "newFillType:" << newFillType;
|
||||
//qDebug() << "newFillType:" << newFillType;
|
||||
}
|
||||
}
|
||||
if (lineObjInfo.contains("newFillMode"))
|
||||
|
|
@ -1298,7 +1397,7 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo)
|
|||
QJsonValue value = lineObjInfo.value("newFillMode");
|
||||
if (value.isString()) {
|
||||
newFillMode = value.toString();
|
||||
qDebug() << "newFillMode:" << newFillMode;
|
||||
//qDebug() << "newFillMode:" << newFillMode;
|
||||
}
|
||||
}
|
||||
//
|
||||
|
|
@ -1307,7 +1406,7 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo)
|
|||
QJsonValue value = lineObjInfo.value("newColorRed");
|
||||
if (value.isDouble()) {
|
||||
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");
|
||||
if (value.isDouble()) {
|
||||
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");
|
||||
if (value.isDouble()) {
|
||||
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");
|
||||
if (value.isDouble()) {
|
||||
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");
|
||||
if (value.isString()) {
|
||||
newLithosImage = value.toString();
|
||||
qDebug() << "newLithosImage:" << newLithosImage;
|
||||
//qDebug() << "newLithosImage:" << newLithosImage;
|
||||
}
|
||||
}
|
||||
if (lineObjInfo.contains("new_vMin"))
|
||||
|
|
@ -1351,7 +1450,7 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo)
|
|||
QJsonValue value = lineObjInfo.value("new_vMin");
|
||||
if (value.isDouble()) {
|
||||
new_vMin = value.toDouble();
|
||||
qDebug() << "new_vMin:" << QString::number(new_vMin);
|
||||
//qDebug() << "new_vMin:" << QString::number(new_vMin);
|
||||
}
|
||||
}
|
||||
if (lineObjInfo.contains("new_vMax"))
|
||||
|
|
@ -1359,7 +1458,7 @@ void MainWindowCurve::DisplayLine_One(QJsonObject lineObjInfo)
|
|||
QJsonValue value = lineObjInfo.value("new_vMax");
|
||||
if (value.isDouble()) {
|
||||
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");
|
||||
if (value.isDouble()) {
|
||||
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");
|
||||
if (value.isDouble()) {
|
||||
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");
|
||||
if (value.isDouble()) {
|
||||
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");
|
||||
if (value.isDouble()) {
|
||||
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");
|
||||
if (value.isDouble()) {
|
||||
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");
|
||||
if (value.isDouble()) {
|
||||
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");
|
||||
if (value.isDouble()) {
|
||||
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");
|
||||
if (value.isDouble()) {
|
||||
backColor.setAlpha(value.toInt());
|
||||
qDebug() << "backColorAlpha:" << QString::number(value.toInt());
|
||||
//qDebug() << "backColorAlpha:" << QString::number(value.toInt());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,14 +15,10 @@
|
|||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="1">
|
||||
<item row="1" column="1">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0">
|
||||
<item>
|
||||
<widget class="QTableWidget" name="tableWidget"/>
|
||||
</item>
|
||||
</layout>
|
||||
<widget class="QTableWidget" name="tableWidget"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTableWidget" name="tableWidget_2"/>
|
||||
|
|
|
|||
|
|
@ -881,6 +881,7 @@ void QMyCustomPlot::s_ChangeFillMode(QString strUuid, QString strSlfName, QStrin
|
|||
graph(0)->setChannelFillGraph( this->graph(1));
|
||||
//
|
||||
replot();
|
||||
//update();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user