Use QFile and QTextStream classes to read or write from files.
QFile file("app/native/assets/text.txt");
if (file.exists()) {
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
QTextStream textStream(&file);
QString text = textStream.readAll();
file.close();
}
} else {
qDebug() << "File doesn't exist";
}
Here, readAll() would return whole content of the stream. You can use readLine() method if you want to read only few length of content.