From edebf25747a05a9cc3594d9270c0f93d12e73f2c Mon Sep 17 00:00:00 2001 From: lh <2334563547@qq.com> Date: Fri, 5 Jun 2026 16:23:35 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=BB=9F=E4=B8=80=E5=82=A8=E5=B1=82?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E5=92=8C=E8=A1=A8=E7=9A=AE=E7=B3=BB=E6=95=B0?= =?UTF-8?q?=E5=AF=B9=E8=AF=9D=E6=A1=86=E8=83=8C=E6=99=AF=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 调整抽屉标题区与内容区背景 - 统一图表控件背景为白色 - 移除时间相关表皮系数对话框按钮自定义边框样式 --- Src/nmNum/nmGUI/nmGUIDrawerWidget.cpp | 25 +++++++++-------- Src/nmNum/nmSubWxs/nmWxChartWidget.cpp | 5 ++-- .../nmSubWxs/nmWxPressFlowChartWidget.cpp | 8 ++---- .../nmSubWxs/nmWxReservoirPropertiesDlg.cpp | 3 ++ Src/nmNum/nmSubWxs/nmWxTimeDependentSkin.cpp | 28 ------------------- 5 files changed, 20 insertions(+), 49 deletions(-) diff --git a/Src/nmNum/nmGUI/nmGUIDrawerWidget.cpp b/Src/nmNum/nmGUI/nmGUIDrawerWidget.cpp index 4038d46..d05587f 100644 --- a/Src/nmNum/nmGUI/nmGUIDrawerWidget.cpp +++ b/Src/nmNum/nmGUI/nmGUIDrawerWidget.cpp @@ -9,8 +9,7 @@ nmGUIDrawerWidget::nmGUIDrawerWidget(const QString &sTitle, QWidget *parent) void nmGUIDrawerWidget::initUI() { - // - // + // 创建标题 QWidget *headerWidget = new QWidget(this); headerWidget->setObjectName("headerWidget"); m_pHeaderLayout = new QHBoxLayout(headerWidget); @@ -18,20 +17,23 @@ void nmGUIDrawerWidget::initUI() m_pToggleButton = new QToolButton(this); m_pToggleButton->setArrowType(Qt::DownArrow); + m_pToggleButton->setStyleSheet("QToolButton { background: transparent; border: none; }"); // 设置按钮透明背景 m_pTitleLabel = new QLabel(m_sTitle, this); - m_pTitleLabel->setStyleSheet("font-weight: bold;"); + m_pTitleLabel->setStyleSheet("font-weight: bold; background: transparent;"); // 设置标题透明背景 m_pHeaderLayout->addWidget(m_pToggleButton); m_pHeaderLayout->addWidget(m_pTitleLabel); m_pHeaderLayout->addStretch(); - // + // 创建内容 m_pWidgetContent = new QWidget(this); m_pWidgetContent->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - m_pWidgetContent->setVisible(true); // Ĭչ + m_pWidgetContent->setVisible(true); // 默认展开 + m_pWidgetContent->setObjectName("contentWidget"); // 设置objectName以便样式表定位 + m_pWidgetContent->setAutoFillBackground(true); // 确保内容区白底稳定 - // + // 创建布局 QVBoxLayout *mainLayout = new QVBoxLayout(this); mainLayout->setSpacing(0); mainLayout->setContentsMargins(0, 0, 0, 0); @@ -51,7 +53,7 @@ void nmGUIDrawerWidget::setExpanded(bool expanded) if (expanded != m_bExpanded) { m_bExpanded = expanded; m_pToggleButton->setArrowType(expanded ? Qt::DownArrow : Qt::RightArrow); - m_pWidgetContent->setVisible(expanded); // ֱʾ/ + m_pWidgetContent->setVisible(expanded); emit expansionChanged(expanded); } } @@ -65,12 +67,11 @@ void nmGUIDrawerWidget::setStyleSheet(const QString &style) { QString customStyle = "#headerWidget {" - " background-color: rgb(173, 216, 230);" // ñɫΪdzɫ + " background-color: rgb(173, 216, 230);" // 设置标题栏背景颜色为浅蓝色 " width: 100%;" "}" - "QToolButton {" - "}" - "QLabel {" + "#contentWidget {" + " background-color: white;" // 设置内容区背景颜色为白色 "}"; - QWidget::setStyleSheet(customStyle); // û෽ + QWidget::setStyleSheet(customStyle); // 调用父类方法 } \ No newline at end of file diff --git a/Src/nmNum/nmSubWxs/nmWxChartWidget.cpp b/Src/nmNum/nmSubWxs/nmWxChartWidget.cpp index 09e0ddb..9cb4012 100644 --- a/Src/nmNum/nmSubWxs/nmWxChartWidget.cpp +++ b/Src/nmNum/nmSubWxs/nmWxChartWidget.cpp @@ -58,9 +58,8 @@ void nmWxChartWidget::paintEvent(QPaintEvent *event) width() - marginLeft - marginRight, height() - marginTop - marginBottom); - // 设置背景 - 灰色背景匹配目标样式 - painter.fillRect(rect(), QColor(240, 240, 240)); - painter.fillRect(chartRect, QColor(248, 248, 248)); + painter.fillRect(rect(), Qt::white); + painter.fillRect(chartRect, Qt::white); // 绘制网格、坐标轴、线条和点 drawGrid(painter); diff --git a/Src/nmNum/nmSubWxs/nmWxPressFlowChartWidget.cpp b/Src/nmNum/nmSubWxs/nmWxPressFlowChartWidget.cpp index 626c208..897f5ac 100644 --- a/Src/nmNum/nmSubWxs/nmWxPressFlowChartWidget.cpp +++ b/Src/nmNum/nmSubWxs/nmWxPressFlowChartWidget.cpp @@ -105,12 +105,8 @@ void nmWxPressFlowChartWidget::paintEvent(QPaintEvent *event) void nmWxPressFlowChartWidget::drawBackground(QPainter& painter) { - // 绘制整体背景 - painter.fillRect(rect(), QColor(240, 240, 240)); - - // 绘制绘图区域背景 - painter.fillRect(m_plotArea, QColor(248, 248, 248)); - + painter.fillRect(rect(), Qt::white); + painter.fillRect(m_plotArea, Qt::white); } double nmWxPressFlowChartWidget::calculateTickInterval(double range, bool isYAxisForPressure) diff --git a/Src/nmNum/nmSubWxs/nmWxReservoirPropertiesDlg.cpp b/Src/nmNum/nmSubWxs/nmWxReservoirPropertiesDlg.cpp index b474757..154bc61 100644 --- a/Src/nmNum/nmSubWxs/nmWxReservoirPropertiesDlg.cpp +++ b/Src/nmNum/nmSubWxs/nmWxReservoirPropertiesDlg.cpp @@ -109,12 +109,15 @@ void nmWxReservoirPropertiesDlg::initUI() { QWidget* nmWxReservoirPropertiesDlg::initParametersUI() { QWidget* container = new QWidget; + container->setStyleSheet("background-color: white;"); // 设置容器白底 QVBoxLayout* containerLayout = new QVBoxLayout(container); QScrollArea* scrollArea = new QScrollArea; scrollArea->setWidgetResizable(true); + scrollArea->setStyleSheet("QScrollArea { background-color: white; }"); // 设置滚动区域白底 QWidget* scrollContent = new QWidget; + scrollContent->setStyleSheet("background-color: white;"); // 设置滚动内容白底 QVBoxLayout* contentLayout = new QVBoxLayout(scrollContent); //dimensionlessCheckbox = new QCheckBox(tr("Use dimensionless parameters (M,D)"), container); diff --git a/Src/nmNum/nmSubWxs/nmWxTimeDependentSkin.cpp b/Src/nmNum/nmSubWxs/nmWxTimeDependentSkin.cpp index 523900f..e76dc8f 100644 --- a/Src/nmNum/nmSubWxs/nmWxTimeDependentSkin.cpp +++ b/Src/nmNum/nmSubWxs/nmWxTimeDependentSkin.cpp @@ -538,34 +538,6 @@ void nmWxTimeDependentSkin::initUI() m_pRightInsertBtn->setEnabled(true); m_pRightDeleteBtn->setEnabled(true); - // 为右侧按钮也设置样式 - QString buttonStyle = - "QPushButton {" - " border: 1px solid #ccc;" - " background-color: #f8f8f8;" - " border-radius: 3px;" - " padding: 2px;" - "}" - "QPushButton:hover {" - " background-color: #e8e8e8;" - " border-color: #999;" - "}" - "QPushButton:pressed {" - " background-color: #d8d8d8;" - "}" - "QPushButton:disabled {" - " background-color: #f0f0f0;" - " color: #aaa;" - " border-color: #ddd;" - "}"; - - m_pRightAddBtn->setStyleSheet(buttonStyle); - m_pRightInsertBtn->setStyleSheet(buttonStyle); - m_pRightDeleteBtn->setStyleSheet(buttonStyle); - m_pOkBtn->setStyleSheet(buttonStyle); - m_pCancelBtn->setStyleSheet(buttonStyle); - - // 在初始化时创建图表模式按钮但不显示 createChartModeBtn();