QTextedit to allow only numbers ...
-
hi all...how to all only number in qtextedit
-
i have tried in lineedit ..with the help of QRegularExpression but it is not possible in textedit
-
@karti-gesar
Have you used proper regular expression only for no.?
and for which purpose you want only no. like for mobile no. for getting percentage ect?
or you can use reqexp.setPattern("^[0-9\ \(\)\+]$"); -
If you really need a QTextEdit which is a widget made to hold a document (multiline text or rich-text) but accepting only numbers, it's not made for that, so I think you will have to hack a little bit.
Try to connect a slot to QTextEdit::textChanged() signal, you retrieve the text and play with it.
But, if you only need one line input from your user, for instance phone number, you can use QLineEdit on which you can enforce an input mask using QLineEdit::setInputMask()
-
thanks ji...for your comment....i used lineedit itself