[SOLVED] -Difference between QTextStream and QString
-
QTextStream works somewhat like std::stringstream. So you can do something like this:
@
QTextStream stream;
stream << "Adding" << "text" << "and" << "number" << 56 << '\n';
@Here I have just used it as a easy way to append results to an empty string. You could later retrieve a copy of the string with @stream.readAll()@
You can also use the stream to perform I/O operations on files.
@
QFile data("foo.txt");
if (data.open(QFile::WriteOnly)) {
QTextStream out(&data);
out << "Text that is going to be added to the file\n";
}
@Here I open foo.txt, and add some stuff to it.
As far as why you have to pass your QString to a QTextStream depends on your application. But note that you pass as a pointer, so operations on filmListTS will reflect on filmListStr.
@
QString some_text = "Give me more.";
QTextStream some_stream(&some_text);
some_stream << "That's enough!";
@After that, the content of some_text would be "Give me more. That's enough!".
Have a look at the "documentation":http://qt-project.org/doc/qt-5/QTextStream.html for more details, and possible use cases.