void VPropertyFormWidget::build() { // Clear the old content, delete old widgets d_ptr->EditorWidgets.clear(); if (layout()) { QLayoutItem *child; while (layout()->count() > 0 && (child = layout()->takeAt(0)) != 0) { if (child->widget()) { delete child->widget(); } delete child; } delete layout(); } // Create new content if (d_ptr->Properties.isEmpty()) { return; //... only if there are properties } QFormLayout* tmpFormLayout = new QFormLayout(this); setLayout(tmpFormLayout); for (int i = 0; i < d_ptr->Properties.count(); ++i) { // Get the current property VProperty* tmpProperty = d_ptr->Properties.value(i, nullptr); if (!tmpProperty) { continue; } if (tmpProperty->getRowCount() > 0) { if (tmpProperty->propertyType() == Property::Complex) { buildEditor(tmpProperty, tmpFormLayout, Property::Complex); QWidget *group = new QWidget(this); tmpFormLayout->addRow(group); QFormLayout* subFormLayout = new QFormLayout(group); QMargins margins = subFormLayout->contentsMargins(); margins.setTop(0); margins.setLeft(14); subFormLayout->setContentsMargins(margins); group->setLayout(subFormLayout); QList<VProperty*> children = tmpProperty->getChildren(); for (int j = 0; j < children.size(); ++j) { buildEditor(children[j], subFormLayout); connect(children[j], &VProperty::childChanged, tmpProperty, &VProperty::ValueChildChanged, Qt::UniqueConnection); ++i; d_ptr->Properties.insert(i, children[j]); } } else { // Child properties, the property itself is not being added VPropertyFormWidget* tmpNewFormWidget = new VPropertyFormWidget(tmpProperty, this); tmpFormLayout->addRow(tmpNewFormWidget); d_ptr->EditorWidgets.append(VPropertyFormWidgetPrivate::SEditorWidget(tmpNewFormWidget)); tmpNewFormWidget->setCommitBehaviour(d_ptr->UpdateEditors); } } else if (tmpProperty->type() == "widget") { VWidgetProperty* tmpWidgetProperty = static_cast<VWidgetProperty*>(tmpProperty); tmpFormLayout->addRow(tmpWidgetProperty->getWidget()); d_ptr->EditorWidgets.append(VPropertyFormWidgetPrivate::SEditorWidget(tmpWidgetProperty->getWidget())); } else { buildEditor(tmpProperty, tmpFormLayout); } } }