More fixes and improvements for WDraggableSpinBox
This commit is contained in:
parent
dafa05d5d2
commit
2a0134fbfc
|
@ -155,6 +155,12 @@
|
||||||
<property name="focusPolicy">
|
<property name="focusPolicy">
|
||||||
<enum>Qt::NoFocus</enum>
|
<enum>Qt::NoFocus</enum>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="correctionMode">
|
||||||
|
<enum>QAbstractSpinBox::CorrectToNearestValue</enum>
|
||||||
|
</property>
|
||||||
|
<property name="keyboardTracking">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
<property name="decimals">
|
<property name="decimals">
|
||||||
<number>4</number>
|
<number>4</number>
|
||||||
</property>
|
</property>
|
||||||
|
@ -199,6 +205,12 @@
|
||||||
<property name="focusPolicy">
|
<property name="focusPolicy">
|
||||||
<enum>Qt::NoFocus</enum>
|
<enum>Qt::NoFocus</enum>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="correctionMode">
|
||||||
|
<enum>QAbstractSpinBox::CorrectToNearestValue</enum>
|
||||||
|
</property>
|
||||||
|
<property name="keyboardTracking">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
<property name="decimals">
|
<property name="decimals">
|
||||||
<number>4</number>
|
<number>4</number>
|
||||||
</property>
|
</property>
|
||||||
|
@ -241,7 +253,13 @@
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="focusPolicy">
|
<property name="focusPolicy">
|
||||||
<enum>Qt::NoFocus</enum>
|
<enum>Qt::ClickFocus</enum>
|
||||||
|
</property>
|
||||||
|
<property name="correctionMode">
|
||||||
|
<enum>QAbstractSpinBox::CorrectToNearestValue</enum>
|
||||||
|
</property>
|
||||||
|
<property name="keyboardTracking">
|
||||||
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="decimals">
|
<property name="decimals">
|
||||||
<number>4</number>
|
<number>4</number>
|
||||||
|
@ -290,6 +308,9 @@
|
||||||
<property name="correctionMode">
|
<property name="correctionMode">
|
||||||
<enum>QAbstractSpinBox::CorrectToNearestValue</enum>
|
<enum>QAbstractSpinBox::CorrectToNearestValue</enum>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="keyboardTracking">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
<property name="minimum">
|
<property name="minimum">
|
||||||
<double>0.010000000000000</double>
|
<double>0.010000000000000</double>
|
||||||
</property>
|
</property>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "WDraggableSpinBox.h"
|
#include "WDraggableSpinBox.h"
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QDesktopWidget>
|
#include <QDesktopWidget>
|
||||||
|
#include <QLineEdit>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
|
|
||||||
WDraggableSpinBox::WDraggableSpinBox(QWidget *parent) : QDoubleSpinBox(parent)
|
WDraggableSpinBox::WDraggableSpinBox(QWidget *parent) : QDoubleSpinBox(parent)
|
||||||
|
@ -9,6 +10,7 @@ WDraggableSpinBox::WDraggableSpinBox(QWidget *parent) : QDoubleSpinBox(parent)
|
||||||
mDefaultValue = 0;
|
mDefaultValue = 0;
|
||||||
setMinimum(-1000000.0);
|
setMinimum(-1000000.0);
|
||||||
setMaximum(1000000.0);
|
setMaximum(1000000.0);
|
||||||
|
lineEdit()->installEventFilter(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
WDraggableSpinBox::~WDraggableSpinBox()
|
WDraggableSpinBox::~WDraggableSpinBox()
|
||||||
|
@ -80,9 +82,12 @@ void WDraggableSpinBox::wheelEvent(QWheelEvent *pEvent)
|
||||||
else QDoubleSpinBox::wheelEvent(pEvent);
|
else QDoubleSpinBox::wheelEvent(pEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WDraggableSpinBox::contextMenuEvent(QContextMenuEvent *pEvent)
|
bool WDraggableSpinBox::eventFilter(QObject *, QEvent *pEvent)
|
||||||
{
|
{
|
||||||
pEvent->ignore();
|
if (pEvent->type() == QEvent::MouseButtonPress)
|
||||||
|
setFocus();
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WDraggableSpinBox::SetDefaultValue(double value)
|
void WDraggableSpinBox::SetDefaultValue(double value)
|
||||||
|
|
|
@ -18,7 +18,7 @@ public:
|
||||||
void mouseReleaseEvent(QMouseEvent *pEvent);
|
void mouseReleaseEvent(QMouseEvent *pEvent);
|
||||||
void mouseMoveEvent(QMouseEvent *pEvent);
|
void mouseMoveEvent(QMouseEvent *pEvent);
|
||||||
void wheelEvent(QWheelEvent *pEvent);
|
void wheelEvent(QWheelEvent *pEvent);
|
||||||
void contextMenuEvent(QContextMenuEvent *pEvent);
|
bool eventFilter(QObject *pObj, QEvent *pEvent);
|
||||||
void SetDefaultValue(double value);
|
void SetDefaultValue(double value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
#include "WIntegralSpinBox.h"
|
#include "WIntegralSpinBox.h"
|
||||||
|
#include <QLineEdit>
|
||||||
#include <QWheelEvent>
|
#include <QWheelEvent>
|
||||||
|
|
||||||
WIntegralSpinBox::WIntegralSpinBox(QWidget *pParent) : QSpinBox(pParent)
|
WIntegralSpinBox::WIntegralSpinBox(QWidget *pParent) : QSpinBox(pParent)
|
||||||
{
|
{
|
||||||
|
lineEdit()->installEventFilter(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
WIntegralSpinBox::~WIntegralSpinBox()
|
WIntegralSpinBox::~WIntegralSpinBox()
|
||||||
|
@ -14,3 +16,11 @@ void WIntegralSpinBox::wheelEvent(QWheelEvent *pEvent)
|
||||||
if (!hasFocus()) pEvent->ignore();
|
if (!hasFocus()) pEvent->ignore();
|
||||||
else QSpinBox::wheelEvent(pEvent);
|
else QSpinBox::wheelEvent(pEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool WIntegralSpinBox::eventFilter(QObject *pObj, QEvent *pEvent)
|
||||||
|
{
|
||||||
|
if (pEvent->type() == QEvent::MouseButtonPress)
|
||||||
|
setFocus();
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ public:
|
||||||
explicit WIntegralSpinBox(QWidget *pParent);
|
explicit WIntegralSpinBox(QWidget *pParent);
|
||||||
~WIntegralSpinBox();
|
~WIntegralSpinBox();
|
||||||
void wheelEvent(QWheelEvent *pEvent);
|
void wheelEvent(QWheelEvent *pEvent);
|
||||||
|
bool eventFilter(QObject *pObj, QEvent *pEvent);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // WINTEGRALSPINBOX_H
|
#endif // WINTEGRALSPINBOX_H
|
||||||
|
|
|
@ -94,6 +94,7 @@ void WPropertyEditor::CreateEditor()
|
||||||
|
|
||||||
pSpinBox->setRange(-128, 128);
|
pSpinBox->setRange(-128, 128);
|
||||||
pSpinBox->setFocusPolicy(Qt::StrongFocus);
|
pSpinBox->setFocusPolicy(Qt::StrongFocus);
|
||||||
|
pSpinBox->setContextMenuPolicy(Qt::NoContextMenu);
|
||||||
pSpinBox->setValue(pByteCast->Get());
|
pSpinBox->setValue(pByteCast->Get());
|
||||||
|
|
||||||
mUI.EditorWidget = pSpinBox;
|
mUI.EditorWidget = pSpinBox;
|
||||||
|
@ -108,6 +109,7 @@ void WPropertyEditor::CreateEditor()
|
||||||
|
|
||||||
pSpinBox->setRange(-32768, 32767);
|
pSpinBox->setRange(-32768, 32767);
|
||||||
pSpinBox->setFocusPolicy(Qt::StrongFocus);
|
pSpinBox->setFocusPolicy(Qt::StrongFocus);
|
||||||
|
pSpinBox->setContextMenuPolicy(Qt::NoContextMenu);
|
||||||
pSpinBox->setValue(pShortCast->Get());
|
pSpinBox->setValue(pShortCast->Get());
|
||||||
|
|
||||||
mUI.EditorWidget = pSpinBox;
|
mUI.EditorWidget = pSpinBox;
|
||||||
|
@ -122,6 +124,7 @@ void WPropertyEditor::CreateEditor()
|
||||||
|
|
||||||
pSpinBox->setRange(-2147483648, 2147483647);
|
pSpinBox->setRange(-2147483648, 2147483647);
|
||||||
pSpinBox->setFocusPolicy(Qt::StrongFocus);
|
pSpinBox->setFocusPolicy(Qt::StrongFocus);
|
||||||
|
pSpinBox->setContextMenuPolicy(Qt::NoContextMenu);
|
||||||
pSpinBox->setValue(pLongCast->Get());
|
pSpinBox->setValue(pLongCast->Get());
|
||||||
|
|
||||||
mUI.EditorWidget = pSpinBox;
|
mUI.EditorWidget = pSpinBox;
|
||||||
|
@ -136,6 +139,7 @@ void WPropertyEditor::CreateEditor()
|
||||||
|
|
||||||
pDraggableSpinBox->setDecimals(4);
|
pDraggableSpinBox->setDecimals(4);
|
||||||
pDraggableSpinBox->setFocusPolicy(Qt::StrongFocus);
|
pDraggableSpinBox->setFocusPolicy(Qt::StrongFocus);
|
||||||
|
pDraggableSpinBox->setContextMenuPolicy(Qt::NoContextMenu);
|
||||||
pDraggableSpinBox->setValue(pFloatCast->Get());
|
pDraggableSpinBox->setValue(pFloatCast->Get());
|
||||||
|
|
||||||
mUI.EditorWidget = pDraggableSpinBox;
|
mUI.EditorWidget = pDraggableSpinBox;
|
||||||
|
|
|
@ -13,17 +13,13 @@ WVectorEditor::WVectorEditor(QWidget *pParent) : QWidget(pParent)
|
||||||
mpSpinBoxX->setFocusPolicy(Qt::StrongFocus);
|
mpSpinBoxX->setFocusPolicy(Qt::StrongFocus);
|
||||||
mpSpinBoxY->setFocusPolicy(Qt::StrongFocus);
|
mpSpinBoxY->setFocusPolicy(Qt::StrongFocus);
|
||||||
mpSpinBoxZ->setFocusPolicy(Qt::StrongFocus);
|
mpSpinBoxZ->setFocusPolicy(Qt::StrongFocus);
|
||||||
|
mpSpinBoxX->setContextMenuPolicy(Qt::NoContextMenu);
|
||||||
|
mpSpinBoxY->setContextMenuPolicy(Qt::NoContextMenu);
|
||||||
|
mpSpinBoxZ->setContextMenuPolicy(Qt::NoContextMenu);
|
||||||
connect(mpSpinBoxX, SIGNAL(valueChanged(double)), this, SLOT(SetX(double)));
|
connect(mpSpinBoxX, SIGNAL(valueChanged(double)), this, SLOT(SetX(double)));
|
||||||
connect(mpSpinBoxY, SIGNAL(valueChanged(double)), this, SLOT(SetY(double)));
|
connect(mpSpinBoxY, SIGNAL(valueChanged(double)), this, SLOT(SetY(double)));
|
||||||
connect(mpSpinBoxZ, SIGNAL(valueChanged(double)), this, SLOT(SetZ(double)));
|
connect(mpSpinBoxZ, SIGNAL(valueChanged(double)), this, SLOT(SetZ(double)));
|
||||||
|
|
||||||
/*mpLayout = new QHBoxLayout(this);
|
|
||||||
mpLayout->setContentsMargins(0,0,0,0);
|
|
||||||
mpLayout->addWidget(mpSpinBoxX);
|
|
||||||
mpLayout->addWidget(mpSpinBoxY);
|
|
||||||
mpLayout->addWidget(mpSpinBoxZ);
|
|
||||||
setLayout(mpLayout);*/
|
|
||||||
|
|
||||||
mpGroupBox = new QGroupBox(this);
|
mpGroupBox = new QGroupBox(this);
|
||||||
mpFormLayout = new QFormLayout(mpGroupBox);
|
mpFormLayout = new QFormLayout(mpGroupBox);
|
||||||
mpFormLayout->addRow(new QLabel("X", mpGroupBox), mpSpinBoxX);
|
mpFormLayout->addRow(new QLabel("X", mpGroupBox), mpSpinBoxX);
|
||||||
|
|
Loading…
Reference in New Issue