问题
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 first to a C string using std::string::c_str().
来源:https://stackoverflow.com/questions/1537164/how-to-use-stdstring-in-a-qlineedit