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
There is no functionality difference between string and std::string because they're the same type.
So in our Qt widget application, we have the lineEdit element and a pushbutton whose name is "pushButton". The retrieval of the value of the lineEdit element is done when the push button is clicked. So inside of this clicked function, we specify the variable, textvalue, and set it equal to, ui->lineEdit->displayText();
Try this:
std::string a = "aaa";
lineEdit->setText(QString::fromStdString(a));
You will need Qt with STL support.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With