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