E
E
Evgeny Kramor2019-06-22 21:25:36
C++ / C#
Evgeny Kramor, 2019-06-22 21:25:36

How to display string in label?

string h = ui->lineEdit->text().toStdString();
ui->label_3->setText(h);

error: no viable conversion from 'std::__cxx11::string' (aka 'basic_string') to 'const QString
'

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Ronald McDonald, 2019-06-22
@exgod

Use QString , not strings, why are you converting to stdString at all?

V
vanyamba-electronics, 2019-06-23
@vanyamba-electronics

QString h(ui->lineEdit->text().toStdString().c_str());
ui->label_3->setText(h);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question