Hi,

I want to make my personal speedbox for set a variable type like this:

X 0000, Y 0000, Z 0000, A 000, B 000, C 000

where X,Y,Z can be change from -9999 to 9999 and A,B,C can be change from -270 to 270.

I have write this code

miospinbox.h
Qt Code:
  1. #include <QWidget>
  2. #include <QAbstractSpinBox>
  3. #include <QLineEdit>
  4. #include <QValidator>
  5.  
  6. class miospinbox : public QAbstractSpinBox
  7. {
  8. Q_OBJECT
  9.  
  10. public:
  11. miospinbox();
  12.  
  13. };
To copy to clipboard, switch view to plain text mode 

and miospinbox.cpp

Qt Code:
  1. #include "miospinbox.h"
  2.  
  3. miospinbox::miospinbox()
  4. {
  5. QLineEdit *lineedit = new QLineEdit(this);
  6. //QRegExp rx("-?\\d{1,3}");
  7. QRegExp rx("[1-9]\\d{0,3}");
  8. QValidator *validator = new QRegExpValidator(rx, this);
  9.  
  10. lineedit->setInputMask("\\X 0000\\, Y 0000, Z 0000, \\A 000, \\B 000, \\C 000;0");
  11. lineedit->setValidator(validator);
  12. setLineEdit(lineedit);
  13. }
To copy to clipboard, switch view to plain text mode 

The validator in not ok, I see this, but setInputMask I think is ok.
When I show the myspinbox on the window, I'can not change the number with keyboard and I can not change with the mouse clicking on arrow of the spinbox.