Gui: [skip ci] workaround for QWindowsStyle to disable spin buttons when it is set read-only
This commit is contained in:
@@ -29,6 +29,9 @@
|
||||
# include <QStyle>
|
||||
# include <QLineEdit>
|
||||
# include <QKeyEvent>
|
||||
# include <QStyle>
|
||||
# include <QStyleOptionSpinBox>
|
||||
# include <QStylePainter>
|
||||
#endif
|
||||
|
||||
#include "SpinBox.h"
|
||||
@@ -409,6 +412,21 @@ void UIntSpinBox::keyPressEvent(QKeyEvent *event)
|
||||
QAbstractSpinBox::keyPressEvent(event);
|
||||
}
|
||||
|
||||
void UIntSpinBox::paintEvent(QPaintEvent*)
|
||||
{
|
||||
QStyleOptionSpinBox opt;
|
||||
initStyleOption(&opt);
|
||||
if (hasExpression()) {
|
||||
opt.activeSubControls &= ~QStyle::SC_SpinBoxUp;
|
||||
opt.activeSubControls &= ~QStyle::SC_SpinBoxDown;
|
||||
opt.state &= ~QStyle::State_Active;
|
||||
opt.stepEnabled = StepNone;
|
||||
}
|
||||
|
||||
QStylePainter p(this);
|
||||
p.drawComplexControl(QStyle::CC_SpinBox, opt);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
IntSpinBox::IntSpinBox(QWidget* parent) : QSpinBox(parent) {
|
||||
@@ -587,6 +605,21 @@ void IntSpinBox::keyPressEvent(QKeyEvent *event)
|
||||
QAbstractSpinBox::keyPressEvent(event);
|
||||
}
|
||||
|
||||
void IntSpinBox::paintEvent(QPaintEvent*)
|
||||
{
|
||||
QStyleOptionSpinBox opt;
|
||||
initStyleOption(&opt);
|
||||
if (hasExpression()) {
|
||||
opt.activeSubControls &= ~QStyle::SC_SpinBoxUp;
|
||||
opt.activeSubControls &= ~QStyle::SC_SpinBoxDown;
|
||||
opt.state &= ~QStyle::State_Active;
|
||||
opt.stepEnabled = StepNone;
|
||||
}
|
||||
|
||||
QStylePainter p(this);
|
||||
p.drawComplexControl(QStyle::CC_SpinBox, opt);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
DoubleSpinBox::DoubleSpinBox(QWidget* parent): QDoubleSpinBox(parent) {
|
||||
@@ -764,4 +797,19 @@ void DoubleSpinBox::keyPressEvent(QKeyEvent *event)
|
||||
QAbstractSpinBox::keyPressEvent(event);
|
||||
}
|
||||
|
||||
void DoubleSpinBox::paintEvent(QPaintEvent*)
|
||||
{
|
||||
QStyleOptionSpinBox opt;
|
||||
initStyleOption(&opt);
|
||||
if (hasExpression()) {
|
||||
opt.activeSubControls &= ~QStyle::SC_SpinBoxUp;
|
||||
opt.activeSubControls &= ~QStyle::SC_SpinBoxDown;
|
||||
opt.state &= ~QStyle::State_Active;
|
||||
opt.stepEnabled = StepNone;
|
||||
}
|
||||
|
||||
QStylePainter p(this);
|
||||
p.drawComplexControl(QStyle::CC_SpinBox, opt);
|
||||
}
|
||||
|
||||
#include "moc_SpinBox.cpp"
|
||||
|
||||
Reference in New Issue
Block a user