-1

I want to input a number in QLienEdit and the range should during 0 and the max number we have got.

rxy
  • 1

1 Answers1

1

Use QLineEdit::setValidator

Sets the validator for values of line edit to v.

The line edit's returnPressed() and editingFinished() signals will only be emitted if v validates the line edit's content as Acceptable. The user may change the content to any Intermediate value during editing, but will be prevented from editing the text to a value that v validates as Invalid.

This allows you to constrain the text that shall finally be entered when editing is done, while leaving users with enough freedom to edit the text from one valid state to another.

If v == 0, setValidator() removes the current input validator. The initial setting is to have no input validator (i.e. any input is accepted up to maxLength()).

The following examples show you how to use this function.

  1. https://doc.qt.io/qt-5/qtwidgets-widgets-lineedits-example.html
  2. Qt QLineEdit Input Validation
Ted
  • 468
  • 2
  • 8