Results 1 to 3 of 3

Thread: error: void value not ignored as it ought to be

  1. #1
    Join Date
    Feb 2008
    Posts
    102
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default error: void value not ignored as it ought to be

    What's wrong?

    Qt Code:
    1. void XmlGenerator::sourceWrite(QTextEdit* editor){
    2. if(!f->open(QIODevice::ReadWrite|QIODevice::Truncate))
    3. std::cout<<"f problem"<<std::endl;
    4.  
    5. if(!file->open(QIODevice::ReadWrite))
    6. std::cout<<"f problem"<<std::endl;
    7.  
    8. QTextStream in(file);
    9. QTextStream out(f);
    10. QString line;
    11. while(!(line=in.readLine()).isNull()){
    12. if(!line.isEmpty()){
    13. if(line.at(0).toLatin1() != '<'){
    14. out<<line<<"\n";
    15. editor->setPlainText(line)<<"\n";
    16. }
    17. }
    18. }//while
    19. out<<"END";
    20. editor->setPlainText("END");
    21. f->close();
    22. file->close();
    23. }
    To copy to clipboard, switch view to plain text mode 

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

  2. #2
    Join Date
    Apr 2008
    Location
    Pavlodar, Kazakhstan
    Posts
    22
    Thanks
    1
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: error: void value not ignored as it ought to be

    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:
    Qt Code:
    1. line += '\n';
    2. editor->setPlainText(line);
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Feb 2008
    Posts
    102
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Talking Re: error: void value not ignored as it ought to be

    Qt Code:
    1. editor->insertPlainText(line+"\n");
    To copy to clipboard, switch view to plain text mode 

    it works ........

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.