#include "propertyDialog.h" #include #include PropertyDlg::PropertyDlg(QWidget *parent) : QDialog(parent) ,_curWidget(nullptr) { setWindowTitle("属性显示"); setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint ); _layout = new QVBoxLayout(this); _layout->setContentsMargins(0, 0, 0, 0); setMinimumSize(300, 500); } PropertyDlg::~PropertyDlg() { if(_curWidget) removeContent(_curWidget); } void PropertyDlg::setContent(QWidget* content) { if(content){ if(_layout->count() == 0) _layout->addWidget(content); _curWidget = content; } } void PropertyDlg::removeContent(QWidget* content) { if(content) _layout->removeWidget(content); }