QFile file("tempfile");
if (!file.open(QIODevice::ReadOnly ))
{
return;
}
QTextStream out(stdout);
out.setCodec("UTF-8");
while (!file.atEnd())
{
QString line = file.readLine();
line.remove(0,len);
if(line.contains("error",Qt::CaseSensitive)!=0)
{
out<<line;
list->addItem(line.toAscii());
}
else if(line.contains("warning",Qt::CaseSensitive)!=0)
{
out<<line;
list->addItem(line.toAscii().data());
}
else
{
out<<line;
list->addItem(line.toAscii().data());
}
}

This is how I used QText stream to read from a file ' tempfile ' and write the content to stdout and also to a list widget (list) . I tried file command in console for tempfile

$ file tempfile
tempfile: UTF-8 Unicode text

That is the reason I chose UTF-8 as codec for QTextStream. Still when I print the content of the file into stdout and listwidget some characters are not printing (" ' " for example).Thanks for the reply