QVBoxLayout *m_pvLayout = NULL;
QWidget *m_pWidgetPlay = NULL;

m_pvLayout = new QVBoxLayout(this);
m_pvLayout->setSpacing(0);
m_pvLayout->setContentsMargins(0, 0, 0, 0);
this->setLayout(m_pvLayout);

 

//布局管理器添加控件

m_pWidgetPlay = new QWidget();
m_pWidgetPlay->setStyleSheet("QWidget{background:rgba(0, 200, 44, 1);image:none;}");
m_pvLayout->addWidget(m_pWidgetPlay);

 

//布局管理器移除控件,并将控件释放掉

if (m_pWidgetPlay != nullptr)
{
  m_pvLayout->removeWidget(m_pWidgetPlay);

  delete m_pWidgetPlay;
  m_pWidgetPlay = nullptr;
}

 

posted on 2018-11-27 19:16  邶风  阅读(1500)  评论(0编辑  收藏  举报