1  void MainWindow::on_loadButton_clicked()
2  {
3    QString text;
4    QFile  outFile("file1.txt");
5    if(!outFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
6      QMessageBox::information(this, "Warning","File not open");
7      return;
8    }
9    QTextStream st (&outFile);
10   text = st.readAll();
11   QMessageBox::information(this, "By readAll() method", text);
12   outFile.close();
13   outFile.open(QIODevice::ReadOnly);
14   text = "";
15   QString line;
16   while(!outFile.atEnd()){
17       line = outFile.readLine();
18       text += line;
19   }
20   QMessageBox::information(this, "By readLine method", text);
21 }