0

I am making a calculator in qt. I have a plain text edit box. when I input numbers in it, I want it to print from the right(like any other calculator).

also, I want to disable input of anything except numbers. (little new in qt)

harveyslash
  • 5,906
  • 12
  • 58
  • 111

1 Answers1

3

You just need to use setAlignment(Qt::AlignRight) of your QLineEdit and

QLineEdit::setValidator(), for example:

myLineEdit->setValidator( new QIntValidator(0, 100, this) );

Take alook at this one as well: Set QLineEdit to accept only numbers

Community
  • 1
  • 1
Leo Chapiro
  • 13,678
  • 8
  • 61
  • 92