Optimize code.

This commit is contained in:
zhangjiaping 2021-08-17 15:04:51 +08:00
parent c2a3b603b1
commit c299e43cda
1 changed files with 7 additions and 1 deletions

View File

@ -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);
}