I developed a plugin in which the user can add a length of a line and than the line gets created.

in QtDesigner I used a Spin Box. However, I just realized that a Spin Box takes only values to 99. 300 ist not possible.

Than I thought I could use a Line Edit instead but when running the tool I get the error message "'QLineEdit' object has no attribute 'value'". Is there a Widget I can use so that the user can enter lenghts above 99?

  • Did you try self.dlg.spinBox.setMaximum(300)? *example object name. – Ben W Oct 22 at 12:58
  • 1
    And if you use QLineEdit the text is retrieved with text() method instead of value(). – Ben W Oct 22 at 13:05
  • I retrieve the QLineEdit with text() but afterwards I can parse them to a float or int. That helped me out, thank you. – DGIS Oct 22 at 13:27
  • Great- I have posted my comments as an answer. – Ben W Oct 23 at 2:32

The default maximum for QSpinBox is 99, but you can change this with the setMaximum() method:


Otherwise, if you wish to use a QLineEdit instead, retrieve the value using the text() method. You can then cast it to an integer or a float if you wish:

val = int(line_edit.text())


val = float(line_edit.text())

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.