How to use std::string in a QLineEdit?
问题 I have the following problem. I am trying to integrate a large code written by me with a Qt interface. Some of my functions return std::string . I did not succeed in making QLineEdit::setText accept them (other functions returning char do not give me problems). What should I do? Thanks! Giuseppe 回答1: Try this: std::string a = "aaa"; lineEdit->setText(QString::fromStdString(a)); You will need Qt with STL support. 回答2: There's no constructor for QString that takes a std::string . Convert it