void WWidgetItem::setParentWidget(WWidget *parent) { if (!widget_) return; if (parent) { WContainerWidget *pc = dynamic_cast<WContainerWidget *>(parent); if (widget_->parent()) { if (widget_->parent() != pc) throw WException("Cannot move a WWidgetItem to another container"); } else pc->widgetAdded(widget_.get()); bool flexLayout = dynamic_cast<FlexLayoutImpl *> (parentLayout_->impl()) != 0; if (flexLayout) impl_ = cpp14::make_unique<FlexItemImpl>(this); else impl_ = cpp14::make_unique<StdWidgetItemImpl>(this); } else { WContainerWidget *pc = dynamic_cast<WContainerWidget *>(widget_->parent()); if (pc) pc->widgetRemoved(widget_.get(), true); impl_.reset(); } }