|
|
|
|
@ -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);" // 设置标题栏背景颜色为浅蓝色
|
|
|
|
|
" background-color: rgb(173, 216, 230);" // 设置标题栏背景颜色为浅蓝色
|
|
|
|
|
" width: 100%;"
|
|
|
|
|
"}"
|
|
|
|
|
"QToolButton {"
|
|
|
|
|
"}"
|
|
|
|
|
"QLabel {"
|
|
|
|
|
"#contentWidget {"
|
|
|
|
|
" background-color: white;" // 设置内容区背景颜色为白色
|
|
|
|
|
"}";
|
|
|
|
|
QWidget::setStyleSheet(customStyle); // 调用基类方法
|
|
|
|
|
QWidget::setStyleSheet(customStyle); // 调用父类方法
|
|
|
|
|
}
|