I want to read a text file word by word in Qt4 (to which I am very new to be honest), I want and write in another file one word per line. I could do this in C++ without any prob
You could combine QString::split and QStringList::join to achieve your aim:
#include
#include
#include
#include
int main()
{
QFile ifile("in.txt");
ifile.open(QIODevice::ReadOnly | QIODevice::Text);
// read whole content
QString content = ifile.readAll();
// extract words
QStringList list = content.split(" ");
ifile.close();
QFile ofile("out.txt");
ofile.open(QIODevice::WriteOnly | QIODevice::Text);
QTextStream out(&ofile);
// join QStringList by "\n" to write each single word in an own line
out << list.join("\n");
ofile.close();
return 0;
}