From 4f400bd1c09524b9e075f068e100dd6bff464536 Mon Sep 17 00:00:00 2001 From: simonyan <315082291@qq.com> Date: Thu, 31 Oct 2024 22:15:19 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E5=AF=B9=E7=BB=84=E4=BB=B6=E5=BA=95?= =?UTF-8?q?=E9=83=A8=E5=8A=A0=E5=BC=B9=E7=B0=A7=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CFDStruct/CUIProperty/CUI.cpp | 9 +++++---- CFDStruct/CUIProperty/CUIWidget.cpp | 7 ++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CFDStruct/CUIProperty/CUI.cpp b/CFDStruct/CUIProperty/CUI.cpp index 1b9a961..f94fbe1 100644 --- a/CFDStruct/CUIProperty/CUI.cpp +++ b/CFDStruct/CUIProperty/CUI.cpp @@ -1,4 +1,4 @@ -#include "CUI.h" +#include "CUI.h" #include #include @@ -20,7 +20,6 @@ CUI::CUI(QWidget *parent, CUIConfig *conf): QWidget(parent) { this->conf = conf; -// this->conf->printConfig(); qDebug() << "----------------------"; buildUI(); } @@ -58,10 +57,12 @@ void CUI::buildUI() if (widget) { qDebug() << "----------- ui widget is not null"; QVBoxLayout *layout = new QVBoxLayout; + layout->setSpacing(0); + layout->setMargin(0); layout->addWidget(widget); this->setLayout(layout); -// QSpacerItem* spacer = new QSpacerItem(5000,5000,QSizePolicy::Maximum,QSizePolicy::Maximum); -// layout->addItem(spacer); +// QSpacerItem *verticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); +// layout->addSpacerItem(verticalSpacer); } else { qDebug() << "----------- ui widget is null"; diff --git a/CFDStruct/CUIProperty/CUIWidget.cpp b/CFDStruct/CUIProperty/CUIWidget.cpp index e98d5d7..10482ce 100644 --- a/CFDStruct/CUIProperty/CUIWidget.cpp +++ b/CFDStruct/CUIProperty/CUIWidget.cpp @@ -1,4 +1,4 @@ -#include "CUIWidget.h" +#include "CUIWidget.h" #include "CUIConfig.h" #include "QVBoxLayout" #include @@ -29,6 +29,11 @@ void CUIWidget::iniUI(QVector &subCUI) subCUI.push_back(tmp); m_layout->addWidget(tmp->getUI()); } + // 如果是垂直布局,则添加 底部的弹簧 + if (qobject_cast(m_layout) != nullptr) { + QSpacerItem *verticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); + ((QVBoxLayout*)m_layout)->addSpacerItem(verticalSpacer); + } }