17

I have a QLineEdit that only allows numbers and I want to get the current value from it. I can't figure out how.

ui->lineEdit->setValidator(new QIntValidator(this));
AAEM
  • 1,837
  • 2
  • 18
  • 26
SamuelNLP
  • 4,038
  • 9
  • 59
  • 102

3 Answers3

28

I figured it out:

QString XMAX=ui->lineEdit->text();
xMax=XMAX.toDouble();
SamuelNLP
  • 4,038
  • 9
  • 59
  • 102
2

Or

std::stod(ui->lineEdit->text().toStdString());

but watch out for the encoding.

g24l
  • 3,055
  • 15
  • 28
0

Try this:

ui->leNome->displayText()
Adil B
  • 14,635
  • 11
  • 60
  • 78
Samuel Ives
  • 302
  • 3
  • 14