c++ - 如何在 QLineEdit 中使用 std::string?

标签 c++ qt stdstring qstring

我有以下问题。我正在尝试将我编写的大型代码与 Qt 界面集成。

我的一些函数返回 std::string。我没有成功地让 QLineEdit::setText 接受它们(其他返回 char 的函数不会给我带来问题)。

我该怎么办?谢谢!
朱塞佩

最佳答案

试试这个:

std::string a = "aaa";
lineEdit->setText(QString::fromStdString(a));

您将需要支持 STL 的 Qt。

关于c++ - 如何在 QLineEdit 中使用 std::string?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1537164/

相关文章:

c++ - SFML 2.3.2 与 Linux 中的 Qt 5.7 集成

c++ - 为什么我不能在 C++ 中从单个字符构造 std::string?

c++ - 如何初始化类内浮点常量?

c++ - 在 64 位 Linux 上编译 32 位 Qt - fatal error : gnu/lib-names-32. h

c++ - 为什么可以通过构造函数将临时值分配给引用?

python - 如何使基于 QWidget 的窗口具有透明背景?

c++ - 带空字符的 STL basic_string 长度

c++ - 限制 std::string 分配的数量

c++ - #define 与运算符一起使用

c++ - Console+Windows的窗体