您尚未登录。

楼主 #1 2017-10-24 10:54:04

testbug
会员
注册时间: 2017-10-24
已发帖子: 1
积分: 1

QStringList 导出char* 出错的问题请问应该如何解决?

QQ20171024105141.png
这里的last_line是QString类型,CSVList为QStringlist类型,
但是last_line怎么全部是问号啊!网上查了很多资料,还是不行。
有没有大神解决过这样的情况

离线

#2 2017-10-24 10:56:34

沉鱼
管理员
注册时间: 2017-09-06
已发帖子: 161
积分: 161

Re: QStringList 导出char* 出错的问题请问应该如何解决?

这个问题貌似我也遇到过, 但是忘记怎么解决了。
只能帮顶了

离线

#3 2017-10-24 11:00:22

晕哥
管理员
所在地: 微信 whycan_cn
注册时间: 2017-09-06
已发帖子: 9,223
积分: 9197

Re: QStringList 导出char* 出错的问题请问应该如何解决?

https://stackoverflow.com/questions/5505221/converting-qstring-to-char

This is because toLatin1() returns an object of QByteArray. As it is not actually bound to a variable it is a temporary that is destroyed at the end of the expression. Thus the call to data() here returns a pointer to an internal structure that no longer exists after the ';'.

大意是:

这是因为linatin()返回一个QByteArray的对象。 由于它不是实际绑定到一个变量,它是一个临时的,在表达式的末尾被销毁。 因此,对这个数据()的调用返回一个指向'。'之后不再存在的内部结构的指针。

你试一试这样:

auto xxx = CSVList.at(i);
auto yyy = xxx.toAscii();
auto zzz = yyy.data();





在线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn