优化更改dataPanel逻辑结构

This commit is contained in:
duanshengchao 2024-12-24 20:17:42 +08:00
parent 9b00b92d23
commit f7550112e4
5 changed files with 40 additions and 11 deletions

View File

@ -101,6 +101,13 @@ set(UTIL_FILES
util/Chart/qcustomplot.cpp util/Chart/qcustomplot.cpp
) )
set(DATAPANEL_FILES
dataPanel/dpBaseWidget.h
dataPanel/dpBaseWidget.cpp
dataPanel/dpLineChart.h
dataPanel/dpLineChart.cpp
)
# #
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}) INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR})
@ -111,6 +118,7 @@ if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
${CPP_SOURCE_FILES} ${CPP_SOURCE_FILES}
${UI_FILES} ${UI_FILES}
${UTIL_FILES} ${UTIL_FILES}
${DATAPANEL_FILES}
resource/PowerMaster.qrc resource/PowerMaster.qrc
) )
# Define target properties for Android with Qt 6 as: # Define target properties for Android with Qt 6 as:

View File

@ -89,6 +89,7 @@ private:
void autoSetGeometry(); //在缩放和移动时以其它panel和parent的border为依据自动调整 void autoSetGeometry(); //在缩放和移动时以其它panel和parent的border为依据自动调整
bool m_bMouseEnter; bool m_bMouseEnter;
bool m_bConfigurationComplete;
QString m_strName; QString m_strName;
QSize m_displayAreaSize; QSize m_displayAreaSize;
QRect m_curGeometry; QRect m_curGeometry;

View File

@ -32,15 +32,28 @@ DataPanel::DataPanel(QWidget *parent)
m_strName = ""; m_strName = "";
m_bMouseEnter = false; m_bMouseEnter = false;
m_bConfigurationComplete = false;
m_pContentWidget = nullptr; m_pContentWidget = nullptr;
m_pScrollArea = nullptr; m_pScrollArea = nullptr;
QWidget* centralWidget = new QWidget(this);
centralWidget->setObjectName("centralWidget");
centralWidget->setStyleSheet("QWidget #centralWidget{\n"
" border:2px solid rgb(76,88,105);\n"
" background-color:rgba(36,43,50,250);\n"
"}\n");
QBoxLayout* centralLayout = new QBoxLayout(QBoxLayout::TopToBottom, this);
centralLayout->setContentsMargins(0, 0, 0, 0);
centralLayout->addWidget(centralWidget);
setLayout(centralLayout);
m_pLayout = new QBoxLayout(QBoxLayout::TopToBottom, this); m_pLayout = new QBoxLayout(QBoxLayout::TopToBottom, this);
m_pLayout->setContentsMargins(0, 0, 0, 0); m_pLayout->setContentsMargins(0, 0, 0, 0);
m_pLayout->setSpacing(0); m_pLayout->setSpacing(0);
setLayout(m_pLayout); centralWidget->setLayout(m_pLayout);
m_pConfigurationWidget = new PanelConfigurationWidget(); m_pConfigurationWidget = new PanelConfigurationWidget(this);
setWiget(m_pConfigurationWidget); m_pConfigurationWidget->raise();
//setWiget(m_pConfigurationWidget);
//resize(533, 300); //resize(533, 300);
m_pCustomBorderContainer = new CustomBorderContainer(this); m_pCustomBorderContainer = new CustomBorderContainer(this);
@ -76,9 +89,17 @@ bool DataPanel::event(QEvent* event)
if (pKeyEvent->key() == Qt::Key_Escape) if (pKeyEvent->key() == Qt::Key_Escape)
return true; return true;
} }
else if(event->type() == QEvent::Resize) else if(event->type() == QEvent::Show)
{ {
m_pToolWidget->move(this->width() - m_pToolWidget->width() - 8, 3); m_pToolWidget->move(this->width() - m_pToolWidget->width() - 8, 3);
m_pConfigurationWidget->move((this->width() - m_pConfigurationWidget->width()) * 0.5, (this->height() - m_pConfigurationWidget->height()) * 0.5);
}
else if(event->type() == QEvent::Resize || event->type() == QEvent::Move)
{
if(m_pToolWidget->isVisible())
m_pToolWidget->move(this->width() - m_pToolWidget->width() - 8, 3);
if(m_pConfigurationWidget->isVisible())
m_pConfigurationWidget->move((this->width() - m_pConfigurationWidget->width()) * 0.5, (this->height() - m_pConfigurationWidget->height()) * 0.5);
} }
else if(event->type() == QEvent::MouseButtonPress) else if(event->type() == QEvent::MouseButtonPress)
{ {

View File

@ -30,11 +30,11 @@
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="QWidget" name="contentWidget" native="true"> <widget class="QWidget" name="centralWidget" native="true">
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">QWidget #contentWidget <string notr="true">QWidget #centralWidget
{ {
border:1px solid rgb(76,88,105); border:2px solid rgb(76,88,105);
background-color:rgba(36,43,50,250); background-color:rgba(36,43,50,250);
}</string> }</string>
</property> </property>

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>710</width> <width>365</width>
<height>400</height> <height>94</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -37,8 +37,7 @@
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">QWidget #contentWidget <string notr="true">QWidget #contentWidget
{ {
border:2px solid rgb(76,88,105); background-color:transparent;
background-color:rgb(24,32,38);
}</string> }</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">