mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#2173 Push button editor now right aligns and has sensible size in steps
This commit is contained in:
parent
df8d23efb9
commit
41a533b6cd
@ -45,6 +45,7 @@
|
||||
#include "cafPdmField.h"
|
||||
|
||||
#include "cafFactory.h"
|
||||
#include "QBoxLayout"
|
||||
|
||||
|
||||
|
||||
@ -97,6 +98,10 @@ void PdmUiPushButtonEditor::configureAndUpdateUi(const QString& uiConfigName)
|
||||
m_pushButton->setText(variantFieldValue.toString());
|
||||
}
|
||||
}
|
||||
|
||||
QSize defaultSize = m_pushButton->sizeHint();
|
||||
m_pushButton->setMinimumWidth(10*std::round(0.1*(defaultSize.width() + 10)));
|
||||
m_buttonLayout->setAlignment(m_pushButton, Qt::AlignRight);
|
||||
|
||||
if (variantFieldValue.type() == QVariant::Bool)
|
||||
{
|
||||
@ -129,9 +134,19 @@ void PdmUiPushButtonEditor::configureEditorForField(PdmFieldHandle* fieldHandle)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QWidget* PdmUiPushButtonEditor::createEditorWidget(QWidget * parent)
|
||||
{
|
||||
m_pushButton = new QPushButton("", parent);
|
||||
QWidget* containerWidget = new QWidget(parent);
|
||||
|
||||
m_pushButton = new QPushButton("", containerWidget);
|
||||
connect(m_pushButton, SIGNAL(clicked(bool)), this, SLOT(slotClicked(bool)));
|
||||
return m_pushButton;
|
||||
|
||||
m_buttonLayout = new QHBoxLayout(containerWidget);
|
||||
m_buttonLayout->addWidget(m_pushButton);
|
||||
m_buttonLayout->setMargin(0);
|
||||
m_buttonLayout->setSpacing(0);
|
||||
|
||||
containerWidget->setLayout(m_buttonLayout);
|
||||
|
||||
return containerWidget;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include <QPointer>
|
||||
#include <QPushButton>
|
||||
#include <QLabel>
|
||||
class QHBoxLayout;
|
||||
|
||||
namespace caf
|
||||
{
|
||||
@ -81,6 +82,7 @@ protected slots:
|
||||
private:
|
||||
QPointer<QPushButton> m_pushButton;
|
||||
QPointer<QLabel> m_label;
|
||||
QPointer<QHBoxLayout> m_buttonLayout;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user