[英]How do I write QList Stored items using qt's QTextStream?
That is how i tried it at first but i get an error "no operator found that takes a left hand operand of type 'QTextStream' or there is no acceptable conversion" 那是我一开始尝试的方式,但是却收到错误消息“找不到运算符,该运算符使用'QTextStream'类型的左手操作数,或者没有可接受的转换”
QList<QString>lNamesList;
void write(){
QFile data("E:/Test/output.h");
if (data.open(QFile::WriteOnly))
{
QTextStream out (&data);
nameList.append("Name1");
out << NameList;
}
}
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
write();
return a.exec();
}
You cannot feed your nameList
directly to your QTextStream
. 您不能将nameList
直接提供给QTextStream
。 You can give it a string or QString
. 您可以给它一个string or QString
。 So you might want to loop over your QList
which would look something like this: 因此,您可能希望遍历QList
,如下所示:
for(const QString& str : nameList){
out << str;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.