#include #include #include "formatterspinbox.h" FormatterSpinBox::FormatterSpinBox(QWidget *parent) : QSpinBox(parent) { m_nwidth = 2; } //! [1] int FormatterSpinBox::valueFromText(const QString &text) const { return text.toInt(); } //! [1] //! [2] QString FormatterSpinBox::textFromValue(int value) const { QString strTemp; return tr("%1").arg(value,m_nwidth,10,QLatin1Char('0')); } //! [2] void FormatterSpinBox::setFormatterWidth(int wid){ m_nwidth = wid; } void FormatterSpinBox::focusInEvent(QFocusEvent *event){ QTimer::singleShot(200,this,SLOT(selectAll())); } void FormatterSpinBox::mouseReleaseEvent(QMouseEvent *event){ this->selectAll(); }