1、构建多选表格组件;
parent
7a3e216e0f
commit
696f581460
@ -0,0 +1,11 @@
|
|||||||
|
#include "CFDStructDataSolverMonitorAerodynamicManager.h"
|
||||||
|
|
||||||
|
CFDStructDataSolverMonitorAerodynamicManager::CFDStructDataSolverMonitorAerodynamicManager(QObject *parent) : CFDStructDataSolverBasicModelManager(parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
CUIConfig *CFDStructDataSolverMonitorAerodynamicManager::getParamUIConfig()
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
#ifndef CFDSTRUCTDATASOLVERMONITORAERODYNAMICMANAGER_H
|
||||||
|
#define CFDSTRUCTDATASOLVERMONITORAERODYNAMICMANAGER_H
|
||||||
|
|
||||||
|
#include "CFDStructDataSolverBasicModelManager.h"
|
||||||
|
|
||||||
|
class CFDStructDataSolverMonitorAerodynamicManager : public CFDStructDataSolverBasicModelManager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit CFDStructDataSolverMonitorAerodynamicManager(QObject *parent = nullptr);
|
||||||
|
CUIConfig* getParamUIConfig();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CFDSTRUCTDATASOLVERMONITORAERODYNAMICMANAGER_H
|
@ -0,0 +1,11 @@
|
|||||||
|
#include "CFDStructDataSolverMonitorImpellerManager.h"
|
||||||
|
|
||||||
|
CFDStructDataSolverMonitorImpellerManager::CFDStructDataSolverMonitorImpellerManager(QObject *parent) : CFDStructDataSolverBasicModelManager(parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
CUIConfig *CFDStructDataSolverMonitorImpellerManager::getParamUIConfig()
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
#ifndef CFDSTRUCTDATASOLVERMONITORIMPELLERMANAGER_H
|
||||||
|
#define CFDSTRUCTDATASOLVERMONITORIMPELLERMANAGER_H
|
||||||
|
|
||||||
|
#include "CFDStructDataSolverBasicModelManager.h"
|
||||||
|
|
||||||
|
class CFDStructDataSolverMonitorImpellerManager : public CFDStructDataSolverBasicModelManager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit CFDStructDataSolverMonitorImpellerManager(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
CUIConfig* getParamUIConfig();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CFDSTRUCTDATASOLVERMONITORIMPELLERMANAGER_H
|
@ -0,0 +1,12 @@
|
|||||||
|
#include "CFDStructDataSolverMonitorResidualManager.h"
|
||||||
|
|
||||||
|
CFDStructDataSolverMonitorResidualManager::CFDStructDataSolverMonitorResidualManager(QObject *parent) : CFDStructDataSolverBasicModelManager(parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
CUIConfig *CFDStructDataSolverMonitorResidualManager::getParamUIConfig()
|
||||||
|
{
|
||||||
|
return new CUIConfig({
|
||||||
|
{"type", "MultiTableWidget"}}, {});
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
#ifndef CFDSTRUCTDATASOLVERMONITORRESIDUALMANAGER_H
|
||||||
|
#define CFDSTRUCTDATASOLVERMONITORRESIDUALMANAGER_H
|
||||||
|
|
||||||
|
#include "CFDStructDataSolverBasicModelManager.h"
|
||||||
|
|
||||||
|
class CFDStructDataSolverMonitorResidualManager : public CFDStructDataSolverBasicModelManager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit CFDStructDataSolverMonitorResidualManager(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
CUIConfig* getParamUIConfig();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CFDSTRUCTDATASOLVERMONITORRESIDUALMANAGER_H
|
@ -0,0 +1,67 @@
|
|||||||
|
#include "CUIMultiTableWidget.h"
|
||||||
|
#include <QTableWidget>
|
||||||
|
#include <QTableWidgetItem>
|
||||||
|
#include <QHeaderView>
|
||||||
|
#include <QList>
|
||||||
|
#include <QPair>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QCheckBox>
|
||||||
|
#include "CUI.h"
|
||||||
|
|
||||||
|
CUIMultiTableWidget::CUIMultiTableWidget(CUIConfig* conf, QVector<CUI*> &subCUI, QWidget *parent) : CUIComponentBaseWidget(parent)
|
||||||
|
{
|
||||||
|
this->initUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CUIMultiTableWidget::initUI()
|
||||||
|
{
|
||||||
|
QStringList headers;
|
||||||
|
headers<<tr("index")<<tr("name")<<tr("view");
|
||||||
|
QList<QList<QString>> items;
|
||||||
|
QList<QString> item1 = {tr("quaility"), "quaility"};
|
||||||
|
QList<QString> item2 = {tr("x"), "x"};
|
||||||
|
QList<QString> item3 = {tr("y"), "y"};
|
||||||
|
QList<QString> item4 = {tr("z"), "z"};
|
||||||
|
items.append(item1);
|
||||||
|
items.append(item2);
|
||||||
|
items.append(item3);
|
||||||
|
items.append(item4);
|
||||||
|
// 根据配置来初始化tableWidget
|
||||||
|
m_tableWidget = new QTableWidget(this);
|
||||||
|
m_tableWidget->setColumnCount(items.count() + 2);
|
||||||
|
m_tableWidget->setRowCount(items.count());
|
||||||
|
m_tableWidget->setHorizontalHeaderLabels(headers);
|
||||||
|
// 设置水平表头的背景颜色
|
||||||
|
m_tableWidget->setStyleSheet(QString(u8"QHeaderView::section{background-color: rgb(226,234,243); color: black; border:1px solid rgb(255, 255, 255);}"));
|
||||||
|
m_tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers); // 禁止编辑
|
||||||
|
m_tableWidget->setFocusPolicy(Qt::NoFocus);
|
||||||
|
// 隐藏垂直表头
|
||||||
|
QHeaderView *verticalHeader = m_tableWidget->verticalHeader();
|
||||||
|
verticalHeader->setVisible(false);
|
||||||
|
|
||||||
|
for (int i=0;i<items.count();i++) {
|
||||||
|
QList<QString> item = items[i];
|
||||||
|
// 序号
|
||||||
|
QTableWidgetItem* indexItem = new QTableWidgetItem(QString("%1").arg(i+1));
|
||||||
|
indexItem->setFlags(indexItem->flags() &~Qt::ItemIsSelectable);
|
||||||
|
indexItem->setTextAlignment(Qt::AlignCenter); // 设置水平居中
|
||||||
|
m_tableWidget->setItem(i,0, indexItem);
|
||||||
|
// 内容
|
||||||
|
for (int j=0;j<item.count();j++) {
|
||||||
|
QTableWidgetItem* nameItem = new QTableWidgetItem(item[j]);
|
||||||
|
nameItem->setFlags(indexItem->flags() &~Qt::ItemIsSelectable);
|
||||||
|
nameItem->setTextAlignment(Qt::AlignCenter); // 设置水平居中
|
||||||
|
m_tableWidget->setItem(i,j+1, nameItem);
|
||||||
|
}
|
||||||
|
// 复选框
|
||||||
|
QTableWidgetItem *checkBoxItem = new QTableWidgetItem();
|
||||||
|
m_tableWidget->setItem(i,item.count() + 1, checkBoxItem);
|
||||||
|
QCheckBox* checkBox = new QCheckBox();
|
||||||
|
checkBox->setStyleSheet("margin-left:45%; margin-right:45%;");// 设置水平居中
|
||||||
|
m_tableWidget->setCellWidget(i, item.count() + 1, checkBox);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_layout = new QVBoxLayout;
|
||||||
|
m_layout->addWidget(m_tableWidget);
|
||||||
|
this->setLayout(m_layout);
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
#ifndef CUIMULTITABLEWIDGET_H
|
||||||
|
#define CUIMULTITABLEWIDGET_H
|
||||||
|
|
||||||
|
#include "CUIComponentBaseWidget.h"
|
||||||
|
#include "CUIComponentBase.h"
|
||||||
|
|
||||||
|
class QTableWidget;
|
||||||
|
class CUI;
|
||||||
|
|
||||||
|
class CUIMultiTableWidget : public CUIComponentBaseWidget, public CUIComponentBase
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit CUIMultiTableWidget(CUIConfig* conf, QVector<CUI*> &subCUI, QWidget *parent = nullptr);
|
||||||
|
protected:
|
||||||
|
void initUI();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QTableWidget* m_tableWidget;
|
||||||
|
signals:
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CUIMULTITABLEWIDGET_H
|
Loading…
Reference in New Issue