From c299e43cdae298b5a217eeabd15347fa4f7939f4 Mon Sep 17 00:00:00 2001 From: zhangjiaping Date: Tue, 17 Aug 2021 15:04:51 +0800 Subject: [PATCH] Optimize code. --- src/frontend/list-items/listitem.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/frontend/list-items/listitem.cpp b/src/frontend/list-items/listitem.cpp index 2909506c..5b662e49 100644 --- a/src/frontend/list-items/listitem.cpp +++ b/src/frontend/list-items/listitem.cpp @@ -14,6 +14,7 @@ ListItem::~ListItem() { delete m_netButton; m_netButton = NULL; + delete m_infoButton; m_infoButton = NULL; } @@ -26,19 +27,24 @@ void ListItem::setName(const QString &name) void ListItem::initUI() { m_mainLayout = new QVBoxLayout(this); - this->setLayout(m_mainLayout); m_mainLayout->setContentsMargins(MAIN_LAYOUT_MARGINS); m_mainLayout->setSpacing(MAIN_LAYOUT_SPACING); + this->setLayout(m_mainLayout); + m_itemFrame = new QFrame(this); + m_hItemLayout = new QHBoxLayout(m_itemFrame); m_hItemLayout->setContentsMargins(ITEM_FRAME_MARGINS); m_hItemLayout->setSpacing(ITEM_FRAME_SPACING); + m_netButton = new NetButton(m_itemFrame); m_nameLabel = new QLabel(m_itemFrame); m_infoButton = new InfoButton(m_itemFrame); + m_hItemLayout->addWidget(m_netButton); m_hItemLayout->addWidget(m_nameLabel); m_hItemLayout->addStretch(); m_hItemLayout->addWidget(m_infoButton); + m_mainLayout->addWidget(m_itemFrame); }