Reworking value editro, part I
This commit is contained in:
@@ -1,19 +1,21 @@
|
||||
|
||||
//#include <QApplication>
|
||||
#include <QVBoxLayout>
|
||||
//#include <QStyledItemDelegate>
|
||||
#include <QSlider>
|
||||
#include <QPushButton>
|
||||
|
||||
#include <bcvalueeditor.h>
|
||||
#include <bcsliderstyle.h>
|
||||
#include <bcvalueeditor.h>
|
||||
|
||||
|
||||
|
||||
BCValueEditor::BCValueEditor(const BCValue& bcValue, QWidget *parent )
|
||||
: QWidget(parent), _bcValue{bcValue}
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
_slider->setStyle(new BCSliderStyle());
|
||||
setAutoFillBackground(true);
|
||||
QSizePolicy sp = _commitButton->sizePolicy();
|
||||
sp.setRetainSizeWhenHidden(true); // <--- Das ist der magische Schalter
|
||||
_commitButton->setSizePolicy(sp);
|
||||
|
||||
/*
|
||||
_slider = new QSlider(Qt::Horizontal, this);
|
||||
_slider->setRange(0, 100);
|
||||
_slider->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||
@@ -34,7 +36,7 @@ BCValueEditor::BCValueEditor(const BCValue& bcValue, QWidget *parent )
|
||||
layout->addWidget(_slider);
|
||||
layout->addWidget(_commitButton);
|
||||
setLayout(layout);
|
||||
|
||||
*/
|
||||
// Wenn Slider bewegt wird -> Signal nach außen senden
|
||||
connect(_slider, &QSlider::valueChanged, this, [this](int val)
|
||||
{
|
||||
@@ -42,13 +44,16 @@ BCValueEditor::BCValueEditor(const BCValue& bcValue, QWidget *parent )
|
||||
});
|
||||
|
||||
// Wenn Reset gedrückt wird -> Slider auf 0 (löst auch valueChanged aus)
|
||||
connect(_commitButton, &QPushButton::clicked, this, [this](){
|
||||
connect(_commitButton, &QPushButton::clicked, this, [this]()
|
||||
{
|
||||
_slider->setValue(0);
|
||||
});
|
||||
//_commitButton->setVisible( false);
|
||||
}
|
||||
|
||||
int BCValueEditor::getValue() const
|
||||
{
|
||||
qDebug() << " -- jajaja: "<< size();
|
||||
return _slider->value();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user