PDA

View Full Version : error: void value not ignored as it ought to be



dreamer
5th May 2008, 15:53
What's wrong?



void XmlGenerator::sourceWrite(QTextEdit* editor){
if(!f->open(QIODevice::ReadWrite|QIODevice::Truncate))
std::cout<<"f problem"<<std::endl;

if(!file->open(QIODevice::ReadWrite))
std::cout<<"f problem"<<std::endl;

QTextStream in(file);
QTextStream out(f);
QString line;
while(!(line=in.readLine()).isNull()){
if(!line.isEmpty()){
if(line.at(0).toLatin1() != '<'){
out<<line<<"\n";
editor->setPlainText(line)<<"\n";
}
}
}//while
out<<"END";
editor->setPlainText("END");
f->close();
file->close();
}


If I put a comment on line number 15, it compiles without any error, so i think that line is the problem........

mitro
5th May 2008, 16:11
I guess line 15 is really incorrect. editor->setPlainText(line) returns void so you should not use << on it. I think it'd be better to rewrite it like this:

line += '\n';
editor->setPlainText(line);

dreamer
5th May 2008, 16:17
editor->insertPlainText(line+"\n");


it works ........