Hello,

I'm quite new to QT. I decided to start learning it after learning to do some console app programming. I'm still going through tutorials and what not. I've got a bit of code here, and I'm not sure what needs fixing.

Qt Code:
  1. #include <QtCore/QCoreApplication>
  2. #include <QDebug>
  3. #include <QString>
  4. #include <QFile>
  5. #include <QTextStream>
  6. #include <iostream>
  7.  
  8. using namespace std;
  9.  
  10. void Write(QString filename);
  11. void Read (QString filename);
  12.  
  13.  
  14. int main(int argc, char *argv[])
  15. {
  16. QCoreApplication a(argc, argv);
  17.  
  18. QString filename = "C:/myfile.txt";
  19.  
  20. Write(filename);
  21. Read(filename);
  22.  
  23. return a.exec();
  24. }
  25.  
  26. void Write(QString filename){
  27.  
  28. QFile mFile(filename);
  29.  
  30. if (!mFile.open(QFile::WriteOnly | QFile::Text )){
  31.  
  32. cout << "could not write file.";
  33. return;
  34.  
  35. }
  36. QTextStream out(&mFile);
  37. cout << "hello world!!";
  38. mFile.flush();
  39. mFile.close();
  40. }
  41.  
  42. void Read(QString filename){
  43.  
  44. QFile mFile(filename);
  45. if (!mFile.open(QFile::ReadOnly | QFile::Text )){
  46.  
  47. cout << "could not open file for reading.";
  48. return;
  49.  
  50. }
  51. QTextStream in(&mFile);
  52. QString mtext = in.readAll();
  53. QDebug << mtext;
  54.  
  55. in << "hello world!!";
  56. mFile.close();
  57.  
  58. }
To copy to clipboard, switch view to plain text mode 

the error is showing up on line 53.

error: expected unqualified-id before '<<' token