mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Caf Pdm: Centered the labels vertically related to their editor widgets
Vertically streching widgets still have their label aligned with the top edge. p4#: 21512
This commit is contained in:
@@ -262,6 +262,8 @@ void PdmUiDefaultObjectEditor::recursiveSetupFieldsAndGroups(const std::vector<P
|
|||||||
bool labelOnTop = (labelPos == PdmUiItemInfo::TOP);
|
bool labelOnTop = (labelPos == PdmUiItemInfo::TOP);
|
||||||
bool editorSpanBoth = labelOnTop;
|
bool editorSpanBoth = labelOnTop;
|
||||||
|
|
||||||
|
QWidget* fieldEditorWidget = fieldEditor->editorWidget();
|
||||||
|
|
||||||
if (labelPos != PdmUiItemInfo::HIDDEN)
|
if (labelPos != PdmUiItemInfo::HIDDEN)
|
||||||
{
|
{
|
||||||
QWidget* fieldLabelWidget = fieldEditor->labelWidget();
|
QWidget* fieldLabelWidget = fieldEditor->labelWidget();
|
||||||
@@ -271,7 +273,12 @@ void PdmUiDefaultObjectEditor::recursiveSetupFieldsAndGroups(const std::vector<P
|
|||||||
|
|
||||||
// Label widget will span two columns if aligned on top
|
// Label widget will span two columns if aligned on top
|
||||||
int colSpan = labelOnTop ? 2 : 1;
|
int colSpan = labelOnTop ? 2 : 1;
|
||||||
|
// If the label is on the side, and the editor can expand vertically, allign the label with the top edge of the editor
|
||||||
|
if (!labelOnTop && (fieldEditorWidget->sizePolicy().verticalPolicy() & QSizePolicy::ExpandFlag))
|
||||||
parentLayout->addWidget(fieldLabelWidget, currentRowIndex, 0, 1, colSpan, Qt::AlignTop);
|
parentLayout->addWidget(fieldLabelWidget, currentRowIndex, 0, 1, colSpan, Qt::AlignTop);
|
||||||
|
else
|
||||||
|
parentLayout->addWidget(fieldLabelWidget, currentRowIndex, 0, 1, colSpan, Qt::AlignVCenter);
|
||||||
|
|
||||||
fieldLabelWidget->show();
|
fieldLabelWidget->show();
|
||||||
|
|
||||||
if (labelOnTop) currentRowIndex++;
|
if (labelOnTop) currentRowIndex++;
|
||||||
@@ -284,7 +291,6 @@ void PdmUiDefaultObjectEditor::recursiveSetupFieldsAndGroups(const std::vector<P
|
|||||||
editorSpanBoth = true; // To span both columns when there is no label
|
editorSpanBoth = true; // To span both columns when there is no label
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget* fieldEditorWidget = fieldEditor->editorWidget();
|
|
||||||
|
|
||||||
if (fieldEditorWidget)
|
if (fieldEditorWidget)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user