Fix a size policy for widgets in the property browser.

This commit is contained in:
Roman Telezhynskyi 2020-10-29 14:44:32 +02:00
parent d5da8c6799
commit 42afd0e2f6
4 changed files with 8 additions and 6 deletions

View File

@ -49,10 +49,11 @@ VFormulaPropertyEditor::VFormulaPropertyEditor(QWidget *parent)
// Create the tool button // Create the tool button
ToolButton = new QToolButton(this); ToolButton = new QToolButton(this);
ToolButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); ToolButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
ToolButton->setText("..."); ToolButton->setText("...");
ToolButton->setIcon(QIcon("://icon/16x16/fx.png")); ToolButton->setIcon(QIcon("://icon/16x16/fx.png"));
ToolButton->setFixedWidth(20); ToolButton->setIconSize(QSize(16, 16));
ToolButton->setFixedSize(24, 24);
ToolButton->installEventFilter(this); ToolButton->installEventFilter(this);
setFocusProxy(ToolButton); // Make the ToolButton the focus proxy setFocusProxy(ToolButton); // Make the ToolButton the focus proxy
setFocusPolicy(ToolButton->focusPolicy()); setFocusPolicy(ToolButton->focusPolicy());
@ -60,6 +61,7 @@ VFormulaPropertyEditor::VFormulaPropertyEditor(QWidget *parent)
// Create the text label // Create the text label
TextLabel = new QLabel(this); TextLabel = new QLabel(this);
TextLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
TextLabel->setText(formula.getStringValue()); TextLabel->setText(formula.getStringValue());
// The layout (a horizontal layout) // The layout (a horizontal layout)
@ -68,7 +70,7 @@ VFormulaPropertyEditor::VFormulaPropertyEditor(QWidget *parent)
layout->setMargin(0); layout->setMargin(0);
layout->addWidget(TextLabel); layout->addWidget(TextLabel);
// Spacer (this is needed for proper display of the label and button) // Spacer (this is needed for proper display of the label and button)
layout->addSpacerItem(new QSpacerItem(1000000000, 0, QSizePolicy::Expanding, QSizePolicy::Expanding)); layout->addSpacerItem(new QSpacerItem(1000000000, 0, QSizePolicy::Expanding, QSizePolicy::Preferred));
layout->addWidget(ToolButton); layout->addWidget(ToolButton);
} }

View File

@ -63,7 +63,7 @@ QWidget *VPE::VLabelProperty::createEditor(QWidget *parent, const QStyleOptionVi
QLabel* tmpEditor = new QLabel(parent); QLabel* tmpEditor = new QLabel(parent);
tmpEditor->setLocale(parent->locale()); tmpEditor->setLocale(parent->locale());
tmpEditor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); tmpEditor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
tmpEditor->setText(d_ptr->VariantValue.toString()); tmpEditor->setText(d_ptr->VariantValue.toString());
d_ptr->editor = tmpEditor; d_ptr->editor = tmpEditor;

View File

@ -167,7 +167,7 @@ QWidget* VPE::VDoubleProperty::createEditor(QWidget * parent, const QStyleOption
tmpEditor->setMaximum(maxValue); tmpEditor->setMaximum(maxValue);
tmpEditor->setDecimals(Precision); tmpEditor->setDecimals(Precision);
tmpEditor->setSingleStep(singleStep); tmpEditor->setSingleStep(singleStep);
tmpEditor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); tmpEditor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
tmpEditor->setValue(VProperty::d_ptr->VariantValue.toDouble()); tmpEditor->setValue(VProperty::d_ptr->VariantValue.toDouble());
connect(tmpEditor, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &VIntegerProperty::valueChanged); connect(tmpEditor, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &VIntegerProperty::valueChanged);

View File

@ -58,7 +58,7 @@ QWidget *VPE::VStringProperty::createEditor(QWidget *parent, const QStyleOptionV
tmpEditor->setReadOnly(readOnly); tmpEditor->setReadOnly(readOnly);
tmpEditor->installEventFilter(this); tmpEditor->installEventFilter(this);
tmpEditor->setClearButtonEnabled(clearButton); tmpEditor->setClearButtonEnabled(clearButton);
tmpEditor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); tmpEditor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
tmpEditor->setText(d_ptr->VariantValue.toString()); tmpEditor->setText(d_ptr->VariantValue.toString());
d_ptr->editor = tmpEditor; d_ptr->editor = tmpEditor;