explicit FormBuilderSaveLayoutEntry(QLayoutItem *li = 0) :
item(li), row(-1), column(-1), rowSpan(0), columnSpan(0), alignment(0) {}
+ void setAlignment(Qt::Alignment al);
+
QLayoutItem *item;
int row;
int column;
Qt::Alignment alignment;
};
+// filter out the case of "Spacer" and "QLayoutWidget" widgets
+void FormBuilderSaveLayoutEntry::setAlignment(Qt::Alignment al)
+{
+ if (!item->widget())
+ return;
+
+ const QString className = item->widget()->metaObject()->className();
+ if (className == QLatin1String("Spacer")
+ || className == QLatin1String("QLayoutWidget"))
+ return;
+
+ alignment = al;
+}
+
// Create list from standard box layout
static QList<FormBuilderSaveLayoutEntry> saveLayoutEntries(const QLayout *layout)
{
for (int idx = 0; idx < count; ++idx) {
QLayoutItem *item = layout->itemAt(idx);
FormBuilderSaveLayoutEntry entry(item);
- entry.alignment = item->alignment();
+ entry.setAlignment(item->alignment());
rc.append(entry);
}
}
QLayoutItem *item = gridLayout->itemAt(idx);
FormBuilderSaveLayoutEntry entry(item);
gridLayout->getItemPosition(idx, &entry.row, &entry.column, &entry.rowSpan,&entry.columnSpan);
- entry.alignment = item->alignment();
+ entry.setAlignment(item->alignment());
rc.append(entry);
}
}