Get the value from a QLineEdit
Asked Answered
T

3

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));
Transcendent answered 28/8, 2012 at 14:7 Comment(0)
T
28

I figured it out:

QString XMAX=ui->lineEdit->text();
xMax=XMAX.toDouble();
Transcendent answered 28/8, 2012 at 14:18 Comment(0)
I
2

Or

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

but watch out for the encoding.

Icao answered 19/10, 2015 at 9:38 Comment(1)
This is better (conserves encoding): std::stod(ui->lineEdit->text().toUtf8());Asphaltite
B
0

Try this:

ui->leNome->displayText()
Biafra answered 31/10, 2017 at 12:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.