Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
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
Vicky Sharma last edited by
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\ \(\)\+]$");
Max13 last edited by
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.
thanks ji...for your comment....i used lineedit itself