如何在QLineEdit中使用std :: string? [英] How to use std::string in a QLineEdit?

查看:61
本文介绍了如何在QLineEdit中使用std :: string?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下问题.我正在尝试将自己编写的大型代码与Qt接口集成在一起.

I have the following problem. I am trying to integrate a large code written by me with a Qt interface.

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

Some of my functions return std::string. I did not succeed in making QLine:setText accept them (other functions returning char do not give me problems).

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

What should I do? Thanks!
Giuseppe

推荐答案

尝试一下:

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

您将需要具有STL支持的Qt.

You will need Qt with STL support.

这篇关于如何在QLineEdit中使用std :: string?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆