14.1.  Input Masks

[ fromfile: validation.xml id: inputmask ]

Table 14.1. Mask Characters

CharacterRequired Character in That Position
AASCII alphabetic character - uppercase or lowercase
NASCII alphanumeric character - uppercase or lowercase
XASCII any character
DASCII nonzero digit
9ASCII digit
HHexadecimal digit
BBinary digit

Table 14.2. Mask Meta Characters

CharacterEffect
>The following alphabetic characters are uppercased
<The following alphabetic characters are lowercased
!No further case conversion
\Escape character

Example 14.1. src/validate/inputmask/masktestform.h

[ . . . . ]
class MaskTestForm : public QWidget {
   Q_OBJECT
public:
   MaskTestForm();
public slots:  
   void showResult();
   void installMask();
   void again();
private:
   QLineEdit* m_InputMask;
   QLineEdit* m_StringEntry;
   QLabel* m_Result;
   void setupForm();
};
[ . . . . ]

Example 14.2. src/validate/inputmask/masktestform.cpp

[ . . . . ]
MaskTestForm::MaskTestForm(): m_InputMask(new QLineEdit), 
    m_StringEntry(new QLineEdit), m_Result(new QLabel) {
    setupForm();
    move(500, 500); 1
}
 
void MaskTestForm::setupForm() {
    setWindowTitle("Mask Test Demo");
    QPushButton* againButton = new QPushButton("Another Input Mask", this);
    QPushButton* quitButton = new QPushButton("Quit", this);
    QFormLayout *form = new QFormLayout(this);
    form->addRow("Mask String:", m_InputMask);
    form->addRow("Test Input: ", m_StringEntry);
    form->addRow("Result:", m_Result);
    connect(m_InputMask, SIGNAL(returnPressed()),
            this, SLOT(installMask()));
    connect(m_StringEntry, SIGNAL(returnPressed()),
            this, SLOT(showResult()));
[ . . . . ]
}
void MaskTestForm::installMask() {
    m_StringEntry->setInputMask(m_InputMask->text());
}
[ . . . . ]

1

Start in mid screen (approx).


Figure 14.1.  Input Masks

Input Masks