Пример #1
0
void Widget::addChild(Widget::Ptr child) {
	if (child->parent().get() != this) {
		return child->setParent(shared_from_this());
	}

	m_children.push_back(child);
}
Пример #2
0
void Widget::removeChild(Widget::Ptr child) {
	if (child->parent() != 0) {
		return child->setParent(0);
	}

	auto it = std::find(m_children.begin(), m_children.end(), child);
	if (it != m_children.begin()) {
		m_children.erase(it);
	}
}