formatterspinbox.cpp 507 Bytes
#include <QtWidgets>

#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;
 }