1.套管组件新增4个右键菜单,功能完善。

2.工具栏,追加“选择井”按钮,支持新建多井。
This commit is contained in:
jiayulong 2026-03-23 17:46:26 +08:00
parent 40d908dbaa
commit 252e44d046
10 changed files with 572 additions and 25 deletions

View File

@ -39,11 +39,11 @@ CONFIG(debug, debug|release){
LIBS += -L$$PWD/../../Bin/ -lCallPlugind -lHPluginManaged -lslfiod
} else {
TARGET = PluginUnit
DESTDIR = $$PWD/../../Bin/customPlugin
DESTDIR = $$PWD/../../BinR/customPlugin
MOC_DIR = ../tmp/PluginUnit
UI_DIR = ../tmp/PluginUnit
OBJECTS_DIR = ../tmp/PluginUnit
LIBS += -L$$PWD/../../Bin/ -lCallPlugin -lHPluginManage -lslfio
LIBS += -L$$PWD/../../BinR/ -lCallPlugin -lHPluginManage -lslfio
}
RESOURCES += \

View File

@ -144,22 +144,23 @@ bool CCommonUtils::getAllSlf(QString prjname, QVector<QString> &vecSlfList, QVec
continue;
}
QString wellnameSLf=mssageSlf.Item;
if (wellnameSLf.isEmpty()||wellnameSLf.length()>64||wellnameSLf.indexOf('&')>-1)
//if (wellnameSLf.isEmpty()||wellnameSLf.length()>64||wellnameSLf.indexOf('&')>-1)
{
QFileInfo fileinfo;
fileinfo = QFileInfo(slfFile1);
wellnameSLf = fileinfo.completeBaseName();
}
if(wellnameSLf != wellname)
{
//井次名称不一致
//qDebug() << "井次名称不一致";
delete logioSLf;
continue;
}
// if(wellnameSLf != wellname)
// {
// //井次名称不一致
// //qDebug() << "井次名称不一致";
// delete logioSLf;
// continue;
// }
vecSlfList.append(slfFile1);
delete logioSLf;
break;
}
}
}

View File

@ -81,6 +81,7 @@ SOURCES += \
qmytreewidget.cpp \
qtcommonclass.cpp \
qtprojectwidgets.cpp \
selectwelldialog.cpp \
totalTitleBar.cpp \
transparentdraggableGuan.cpp \
transparentdraggableRightList.cpp \
@ -144,6 +145,7 @@ HEADERS += \
qmytreewidget.h \
qtcommonclass.h \
qtprojectwidgets.h \
selectwelldialog.h \
totalTitleBar.h \
transparentdraggableGuan.h \
transparentdraggableRightList.h \
@ -168,7 +170,8 @@ FORMS += \
mainwindowcurve.ui \
mainwindowsplitter.ui \
newheaddialog.ui \
qtprojectwidgets.ui
qtprojectwidgets.ui \
selectwelldialog.ui
INCLUDEPATH += ../include/ \
../CallManage \

View File

@ -14,6 +14,7 @@
#include "LogModuleConsole.h"
#include "DepPairs.h"
#include "mainwindowsplitter.h"
#include "selectwelldialog.h"
extern int g_iOneWidth; //道宽
extern QString g_prjname;
@ -23,6 +24,7 @@ extern QString g_prjname;
extern double g_dPixelPerCm;//每厘米像素数
extern int g_iShow; //显示刻度
extern int g_SelectWellIndex;
//图头
//extern int g_iRows;
//extern int g_iCols;
@ -188,6 +190,7 @@ void MainWindowCurve::initMainToolBar()
QSize toolIconSize(18, 18);
ui->mainToolBar->setIconSize(toolIconSize); //设置工具栏图标大小
QIcon selectWellIcon(::GetImagePath()+"icon/WellTops.png");
QIcon fixwellsectionHeaderIcon(::GetImagePath()+"icon/fixwellsectionHeader.png");
QIcon currtempliteIcon(::GetImagePath()+"icon/currtemplite.png");
QIcon saveastemplateIcon(::GetImagePath()+"icon/saveastemplate.png");
@ -200,6 +203,7 @@ void MainWindowCurve::initMainToolBar()
QIcon loadIcon(":/image/export.png");
//Main工具栏
QAction* m_selectWellAc = nullptr; //选择井
QAction* m_fixwellsectionHeaderAc = nullptr; //锁头
QAction* m_currtempliteAc = nullptr; //加载图文件
QAction* m_saveastemplateAc = nullptr; //另存为图文件
@ -211,6 +215,7 @@ void MainWindowCurve::initMainToolBar()
// QAction* m_debugAc = nullptr; //
// QAction* m_loadAc = nullptr; //加载
m_selectWellAc = new QAction(selectWellIcon, "选择井", this);
m_fixwellsectionHeaderAc = new QAction(fixwellsectionHeaderIcon, "锁头", this);
m_currtempliteAc = new QAction(currtempliteIcon, "加载图文件", this);
m_saveastemplateAc = new QAction(saveastemplateIcon, "另存为图文件", this);
@ -225,6 +230,7 @@ void MainWindowCurve::initMainToolBar()
ui->mainToolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); //此种方式为文字显示在图标右侧
//add QAction to Widget.
ui->mainToolBar->addAction(m_selectWellAc);
ui->mainToolBar->addAction(m_fixwellsectionHeaderAc);
//ui->mainToolBar->addAction(m_currtempliteAc);
ui->mainToolBar->addAction(m_saveastemplateAc);
@ -237,6 +243,7 @@ void MainWindowCurve::initMainToolBar()
// ui->mainToolBar->addAction(m_loadAc);
//ui->mainToolBar->addAction(m_openAc);
connect(m_selectWellAc, &QAction::triggered, this, &MainWindowCurve::s_selectWell);
connect(m_fixwellsectionHeaderAc, &QAction::triggered, this, &MainWindowCurve::s_showHeadTable);
connect(m_currtempliteAc, &QAction::triggered, this, &MainWindowCurve::s_currtemplite);
connect(m_saveastemplateAc, &QAction::triggered, this, &MainWindowCurve::s_Save);
@ -2318,6 +2325,65 @@ void MainWindowCurve::s_ModuleOpen()
//}
//选择井
void MainWindowCurve::s_selectWell()
{
QStringList listSlf;
QStringList listWell;
//直方图获取当前工程下的slf
QVector<QString> vecSlfList;
QVector<QString> vecWellList;
bool bRet = getAllSlf(g_prjname, vecSlfList, vecWellList);
if(bRet)
{
for(int i=0; i<vecWellList.size(); i++)
{
if(m_listWell.contains(vecWellList[i]))
{
//视图上存在的井,不可选
continue;
}
else
{
listWell.append(vecWellList[i]);
listSlf.append(vecSlfList[i]);
}
}
}
if(listWell.size()<=0)
{
QMessageBox::warning(this, "提示", "没有可选择井", "确定");
return;
}
// 创建对话框
SelectWellDialog *dlg = new SelectWellDialog(nullptr);
dlg->setInfo(listWell, listSlf);
//
dlg->setAttribute(Qt::WA_DeleteOnClose);//关闭时,自动删除窗口对象
int result = dlg->exec();//模态对话框
if (result == QDialog::Accepted) {
// 处理用户点击了确定按钮的逻辑
qDebug() << "Accepted=";
//井没创建,创建井+道+曲线
//新建井
s_NewWell(listWell[g_SelectWellIndex], listSlf[g_SelectWellIndex]);
//新建道
emit CallManage::getInstance()->sig_NewTrack(m_strUuid, listWell[g_SelectWellIndex], "", "", "");
}
else if (result == QDialog::Rejected) {
// 处理用户点击了取消按钮的逻辑
qDebug() << "Rejected=";
}
else {
// 处理其他情况的逻辑
qDebug() << "other=";
}
}
//显示/隐藏图头
void MainWindowCurve::s_showHeadTable()
{
@ -2854,8 +2920,8 @@ void MainWindowCurve::s_NewSantuyibiao()
//选中道
if(m_SelectTableItem.m_iTableType==2) {
//新建表格曲线
emit CallManage::getInstance()->sig_AddTableLine(m_strUuid, m_SelectTableItem.m_strSlfName, m_SelectTableItem.m_strWellName, m_SelectTableItem.m_strTrackName, "IMAGE_DATA");
//斜井三图一表
emit CallManage::getInstance()->sig_AddSantuyibiao(m_strUuid, m_SelectTableItem.m_strSlfName, m_SelectTableItem.m_strWellName, m_SelectTableItem.m_strTrackName, "Santuyibiao");
return;
}
@ -3203,8 +3269,8 @@ void MainWindowCurve::s_NewJiegutext()
//选中道
if(m_SelectTableItem.m_iTableType==2) {
//新建表格曲线
emit CallManage::getInstance()->sig_AddTableLine(m_strUuid, m_SelectTableItem.m_strSlfName, m_SelectTableItem.m_strWellName, m_SelectTableItem.m_strTrackName, "IMAGE_DATA");
//气测/FMT/射孔/文本
emit CallManage::getInstance()->sig_AddJiegutext(m_strUuid, m_SelectTableItem.m_strSlfName, m_SelectTableItem.m_strWellName, m_SelectTableItem.m_strTrackName, "GASLOG");
return;
}
@ -3225,8 +3291,8 @@ void MainWindowCurve::s_NewLogface()
//选中道
if(m_SelectTableItem.m_iTableType==2) {
//新建表格曲线
emit CallManage::getInstance()->sig_AddTableLine(m_strUuid, m_SelectTableItem.m_strSlfName, m_SelectTableItem.m_strWellName, m_SelectTableItem.m_strTrackName, "IMAGE_DATA");
//沉积相
emit CallManage::getInstance()->sig_AddLogface(m_strUuid, m_SelectTableItem.m_strSlfName, m_SelectTableItem.m_strWellName, m_SelectTableItem.m_strTrackName, "LITHA");
return;
}
@ -3258,8 +3324,8 @@ void MainWindowCurve::s_NewTubingstring()
//选中道
if(m_SelectTableItem.m_iTableType==2) {
//新建表格曲线
emit CallManage::getInstance()->sig_AddTableLine(m_strUuid, m_SelectTableItem.m_strSlfName, m_SelectTableItem.m_strWellName, m_SelectTableItem.m_strTrackName, "IMAGE_DATA");
//套管组件
emit CallManage::getInstance()->sig_AddTubingstring(m_strUuid, m_SelectTableItem.m_strSlfName, m_SelectTableItem.m_strWellName, m_SelectTableItem.m_strTrackName, "TUBTOOLS");
return;
}
@ -4386,12 +4452,12 @@ void MainWindowCurve::slotContextMenu(QPoint pos)
if(iCurrentRow == 0)
{
QMenu menu(ui->tableWidget_2);
menu.addAction(QIcon(::GetImagePath() + "antialiasing.png"), "删除当前测井图", this, &MainWindowCurve::slotDeleteSelectTrack);
menu.addAction(QIcon(::GetImagePath() + "antialiasing.png"), "删除当前测井图", this, &MainWindowCurve::slotDeleteSelectWell);
menu.exec(ui->tableWidget_2->mapToGlobal(pos));
}
}
void MainWindowCurve::slotDeleteSelectTrack()
void MainWindowCurve::slotDeleteSelectWell()
{
int colCount = ui->tableWidget_2->columnCount();

View File

@ -164,7 +164,7 @@ public slots:
//右键菜单响应函数
void slotContextMenu(QPoint pos);
void slotDeleteSelectTrack();
void slotDeleteSelectWell();
public slots:
void s_NewWell(QString strWellName, QString strSlfName);//新建井
@ -236,6 +236,7 @@ public slots:
void s_EShiftDepth(QString strSlfName, QString strLineName, int count, QList<double> left_Low_List, QList<double> right_Hight_List);
//
void s_selectWell(); //选择井
void s_showHeadTable(); //显示/隐藏图头
void s_currtemplite(); //加载图文件
void s_Save(); //保存图文件

View File

@ -1354,7 +1354,12 @@ void QMyCustomPlot::contextMenuEvent(QContextMenuEvent *event)
pSubMenu->addAction(QIcon(::GetImagePath() + "icon/OneSideWallCore.png"), str, this, &QMyCustomPlot::addItem_Tubing);
}
}
//menu.addAction(QIcon(::GetImagePath() + "icon/OneSideWallCore.png"), "添加偏配", this, &QMyCustomPlot::addItem_Tubing);
menu.addSeparator();
menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "从剪切板文本数据粘贴", this, &QMyCustomPlot::addItems_Tubing);
menu.addAction(QIcon(::GetImagePath() + "icon/ClearSelectCore.png"), "取消选中", this, &QMyCustomPlot::ClearSelectItems);
menu.addAction(QIcon(::GetImagePath() + "icon/Delete.png"), "全部清空", this, &QMyCustomPlot::DeleteItems_Tubing);
menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "刷新数据", this, &QMyCustomPlot::RefreshItems_Tubing);
menu.exec(event->globalPos());
}
}
@ -4694,6 +4699,8 @@ void QMyCustomPlot::s_changeDepthProperty(QVariantList vlist)
this->replot();
}
}
//校深线段
void QMyCustomPlot::addLineToPlot(double left_Low, double right_Hight, const QString strText, QColor crColor)
{
QtCommonClass *qtCommon = new QtCommonClass(this);
@ -8364,6 +8371,13 @@ void QMyCustomPlot::addItem_Tubing()
//保存
SaveToSLF_Tubing();
if(!mRect_Tubing || !mRect2_Tubing)
{
//绘制结构
DrawStruct();
}
//检查套管组件名称,是否需要更新套管图形
//画管柱
if(str == "管底部" ||
@ -8374,6 +8388,10 @@ void QMyCustomPlot::addItem_Tubing()
//组件改变后,重绘管柱
LoadFromSLF_ReDrawTubing(m_strSlfName, m_strLineName);
}
else{
//刷新
this->replot();
}
}
}
}
@ -8603,6 +8621,12 @@ bool QMyCustomPlot::LoadFromSLF_Tubing(QString strSlfName, QString csCurve)
m_pResultList_Tubing.clear();
cclimgpath_Tubing=GetSymbolDir()+"\\管柱组件\\";
//先删除
if(mPixmap_Tubing)
{
removeItem(mPixmap_Tubing);
mPixmap_Tubing = nullptr;
}
Slf_JIEGUPOS *m_pResult=NULL;
CMemRdWt *logio=new CMemRdWt();
@ -8932,3 +8956,278 @@ bool QMyCustomPlot::checkTubingName(QString m_Result)
}
return false;
}
//粘贴数据成取心
void QMyCustomPlot::addItems_Tubing()
{
int hasNO=0;
int isSK=0;
bool bReDraw = false;
{
QClipboard *clipboard = QApplication::clipboard(); //获取系统剪贴板指针
QString originalTubingstring = clipboard->text(); //获取剪贴板上文本信息
int isspace=originalTubingstring.indexOf(" ");
int istab=originalTubingstring.indexOf("\t");
int isd=originalTubingstring.indexOf(",");
if((istab>-1|isd>-1)&&isspace>-1)
{
QMessageBox::information(NULL,"提示","\",\"或制表符与空格键并存,自动分解可能有误!\n建议用单一符号风格!");
}
originalTubingstring.replace("\t"," ");
originalTubingstring.replace(","," ");
originalTubingstring.replace("\r\n","\n");
originalTubingstring.replace("\r","\n");
QStringList line=originalTubingstring.split("\n");
line.removeAll("");
if(line.size()<1) return;
QString TableName;
QStringList temp1;
if(line.size()>1) {
temp1=line[0].split(" ");
temp1.removeAll("");
if(temp1.size()==1&&temp1.at(0).length()&&!temp1.at(0).at(0).isDigit()) {
TableName=temp1.at(0);
line.removeAt(0);
//CoreObj->SetName(TableName);
}
}
QString ss = m_strSlfName;
CMemRdWt *logio=new CMemRdWt();
if(ss==""||!logio->Open(ss.toStdString().c_str(),CSlfIO::modeReadWrite))
{
delete logio;
QMessageBox::information(NULL,"提示","SLF文件打开失败请检查",QMessageBox::Yes);
return;
}
int k=0;
QStringList coredat=line[0].split(" ");
if((istab==-1||isd==-1)&&isspace>=0) coredat.removeAll("");
int iIndex=logio->OpenTable(m_strLineName.toStdString().c_str());
if(iIndex>=0) {
int count=logio->GetTableFieldCount(iIndex);
if(count!=coredat.size()) {
logio->DiscardObject(m_strLineName.toStdString().c_str());
}
iIndex=-1;
}
bool isfirst=false;
if(iIndex<0)
{
QString name,Length,type,temp;
bool ret=false;
QStringList css;
if(coredat.size()&&!coredat[0].isEmpty()) {
int NUM=0;
if(!coredat.at(0).at(0).isDigit()){
if(coredat.at(0).indexOf("NO",0,Qt::CaseInsensitive)<0
&&coredat.at(0).indexOf("序号")<0
&&coredat.at(0).indexOf("INDEX")<0
&&coredat.at(0).indexOf("ORDER")<0
)
{
coredat.insert(0,"NO");
hasNO=true;
}
}
else {
if(hasNO) coredat.insert(0,QString::number(1));
}
if(m_strLineName=="SK"&&(coredat.size()==4||coredat.size()==5))
{
isSK=1;
name="NO,SDEP,EDEP,ZONE,RESULT,THICK,TT,ZONENO,LAYER,DEST";
Length="4,4,4,8,4,4,4,64,64,64";
type= "1,4,4,6,1,4,4,6,6,6";
temp= "0,0,0,0,1,0,0,0,0,0";
NUM=10;
}
else {
for(int j=0;j<coredat.size();j++)
{
if(j==0) name+="NO";
//else if(j==1) name+="SDEP";
//else if(j==2)name+="EDEP";
if(j==0){
Length+="4";
type+="1";
}
else {
bool isdi=false;
if(css.size()>j)
{
for (int k=0;k<css.at(j).size();k++)
{
if(!css.at(j).at(k).isDigit()&&css.at(j).at(k)!='.'&&css.at(j).at(k)!='-'){
isdi=true;
break;
}
}
}
if(isdi) {
type+="6";
Length+="64";
}
else {
type+="4";
Length+="4";
}
}
if(name.indexOf("Number",0,Qt::CaseInsensitive)>-1) temp+="8";
else temp+"0";
if(j!=coredat.size())
{
name+=",";
Length+=",";
type+=",";
temp+=",";
}
}
if(!coredat.at(0).at(0).isDigit()&&coredat.at(0).at(0)!='.'&&coredat.at(0).at(0)!='-') name=coredat.join(",");
NUM=coredat.size();
}
iIndex=logio->Open_Set_Table(m_strLineName.toStdString().c_str(),0,NUM,
(char*)name.toStdString().c_str(),
(char*)Length.toStdString().c_str(),//字段长度
(char*)type.toStdString().c_str(),//字段类型
(char*)temp.toStdString().c_str());//字段备注,1-枚举
isfirst=true;
logio->SetTableRecordCount(iIndex,0);
}
}
int count=logio->GetTableFieldCount(iIndex);
Slf_TABLE_FIELD*pField=new Slf_TABLE_FIELD[logio->GetTableFieldCount(iIndex)];
logio->GetTableFieldInfo(iIndex,pField);
float yy;
for(int i=0;i<line.size();i++)
{
coredat=line[i].split(" ");
if((istab==-1||isd==-1)&&isspace>=0) coredat.removeAll("");
if(coredat.size()<1) continue;
if(coredat[0].isEmpty()) continue;
if(coredat.size()<2)continue;
if(!coredat.at(0).at(0).isDigit()) continue;
if(hasNO) coredat.insert(0,QString::number(0));
// for(int j=0;j<coredat.size();j++)
// {
// if(isSK&&(coredat.size()==5||coredat.size()==6))
// {
// if(j<3){
// yy=coredat[j].toFloat();
// logio->SetTableFieldData(iIndex,j,(char*)&yy,k+1);
// }
// else if(j==3) logio->SetTableFieldData(iIndex,7,(char*)coredat[j].toStdString().c_str(),k+1);
// else if(j==4) logio->SetTableFieldData(iIndex,8,(char*)coredat[j].toStdString().c_str(),k+1);
// else if(j==5) logio->SetTableFieldData(iIndex,9,(char*)coredat[j].toStdString().c_str(),k+1);
// }
// else {
// if(pField[j].RepCode==6) {
// logio->SetTableFieldData(iIndex,j,(char*)coredat[j].toStdString().c_str(),k+1);
// }
// else {
// yy=coredat[j].toFloat();
// logio->SetTableFieldData(iIndex,j,(char*)&yy,k+1);
// }
// }
// }
// k++;
//AddItem(coredat);
//
double Depth = coredat[1].toDouble();
int Number = coredat[2].toDouble();
Slf_JIEGUPOS result;
result.Depth = Depth;
result.Order = 0;
result.Number = Number;
//
drawOne_Tubing(result);
//还没有画管柱
if(Number == zoneOrder_Tubing.value("管底部").toInt()||
Number == zoneOrder_Tubing.value("油管深").toInt()||
Number == zoneOrder_Tubing.value("喇叭口").toInt()||
Number == zoneOrder_Tubing.value("剌叭口").toInt())
{
bReDraw = true;//重画管柱
}
}
delete logio;
delete []pField;
if(isfirst)
{
AddTableToWellRound();
//绘制结构
DrawStruct();
}
//保存
SaveToSLF_Tubing();
if(bReDraw)
{
//组件改变后,重绘管柱
LoadFromSLF_ReDrawTubing(m_strSlfName, m_strLineName);
}
else
{
//刷新
this->replot();
}
//属性清空
PropertyService()->InitCurrentViewInfo();
}
}
//全部清空
void QMyCustomPlot::DeleteItems_Tubing()
{
if(QMessageBox::information(NULL,QObject::tr("提示"),QObject::tr("该功能将清除当前组件展示的全部信息,清除后无法恢复,但会备份到对应的\"_BAK\"中,确定清除吗?"),QMessageBox::Yes|QMessageBox::No)!=QMessageBox::Yes) return;
QString obj=m_strLineName + "BAK";
CopyToSLFFile(m_strSlfName, false, (char *)obj.toStdString().c_str());
AddTableToWellRound();
//删除对象
TransparentDraggableGuan *pDraggableRect =NULL;
QMap<QString,QObject *>::Iterator it = m_mapDraggable_Guan.begin();
while( it != m_mapDraggable_Guan.end() )
{
pDraggableRect = (TransparentDraggableGuan*)it.value();
it++;
pDraggableRect->deleteRect();
}
//刷新
//this->replot();
//保存
SaveToSLF_Tubing();
//重新加载
LoadFromSLF_Tubing(m_strSlfName, m_strLineName);
//属性清空
PropertyService()->InitCurrentViewInfo();
}
//刷新数据
void QMyCustomPlot::RefreshItems_Tubing()
{
//删除对象
TransparentDraggableGuan *pDraggableRect =NULL;
QMap<QString,QObject *>::Iterator it = m_mapDraggable_Guan.begin();
while( it != m_mapDraggable_Guan.end() )
{
pDraggableRect = (TransparentDraggableGuan*)it.value();
it++;
pDraggableRect->deleteRect();
}
//重新加载
LoadFromSLF_Tubing(m_strSlfName, m_strLineName);
//属性清空
PropertyService()->InitCurrentViewInfo();
}

View File

@ -348,7 +348,8 @@ public:
//套管组件
void addGuanToPlot(double left_Low, double right_Hight, const QString imagePath, float in, bool bRefresh=true);
//
//校深线段
void addLineToPlot(double left_Low, double right_Hight, const QString strText, QColor crColor=QColor(255, 255, 255, 80));
//框选并编辑曲线
@ -476,7 +477,9 @@ public slots:
//右键--套管组件
void addItem_Tubing(); //添加套管组件
//void RefreshItems_Tubing(); //刷新数据
void addItems_Tubing(); //从剪切板文本数据粘贴
void DeleteItems_Tubing();//全部清空
void RefreshItems_Tubing(); //刷新数据
//右键--解释结论
void onOpenEditResult();

View File

@ -0,0 +1,74 @@
#include "selectwelldialog.h"
#include "ui_selectwelldialog.h"
#include <QFile>
#include <QTextStream>
int g_SelectWellIndex = 0;
SelectWellDialog::SelectWellDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::SelectWellDialog)
{
ui->setupUi(this);
loadStyle(":/qrc/qss/flatgray.css");
//
connect(ui->ok, SIGNAL(clicked()), this, SLOT(slotOkClicked()));
connect(ui->cancel, SIGNAL(clicked()), this, SLOT(slotCancelClicked()));
}
SelectWellDialog::~SelectWellDialog()
{
delete ui;
}
void SelectWellDialog::loadStyle(const QString &qssFile)
{
//加载样式表
QString qss;
QFile file(qssFile);
if (file.open(QFile::ReadOnly)) {
//用QTextStream读取样式文件不用区分文件编码 带bom也行
QStringList list;
QTextStream in(&file);
//in.setCodec("utf-8");
while (!in.atEnd()) {
QString line;
in >> line;
list << line;
}
file.close();
qss = list.join("\n");
QString paletteColor = qss.mid(20, 7);
this->setPalette(QPalette(paletteColor));
//用时主要在下面这句
this->setStyleSheet(qss);
}
}
void SelectWellDialog::setInfo(QStringList listWell, QStringList listSlf)
{
for(int i=0; i<listWell.size(); i++)
{
ui->comboBox->addItem(listWell[i]);
}
}
//
void SelectWellDialog::slotOkClicked()
{
g_SelectWellIndex = ui->comboBox->currentIndex();
//关闭
accept(); // 让 QDialog::exec() 返回 QDialog::Accepted
//QDialog::close();
}
//
void SelectWellDialog::slotCancelClicked()
{
reject(); // 让 QDialog::exec() 返回 QDialog::Rejected
//QDialog::close();
}

View File

@ -0,0 +1,30 @@
#ifndef SELECTWELLDIALOG_H
#define SELECTWELLDIALOG_H
#include <QDialog>
namespace Ui {
class SelectWellDialog;
}
class SelectWellDialog : public QDialog
{
Q_OBJECT
public:
explicit SelectWellDialog(QWidget *parent = nullptr);
~SelectWellDialog();
private:
Ui::SelectWellDialog *ui;
public:
void loadStyle(const QString &qssFile);
void setInfo(QStringList listWell, QStringList listSlf);
public slots:
void slotOkClicked();
void slotCancelClicked();
};
#endif // SELECTWELLDIALOG_H

View File

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SelectWellDialog</class>
<widget class="QDialog" name="SelectWellDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>选择井</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,2">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>选择井:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="ok">
<property name="text">
<string>选择</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cancel">
<property name="text">
<string>取消</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>