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.
#include <QtCore/QCoreApplication>
#include <QDebug>
#include <QString>
#include <QFile>
#include <QTextStream>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
QString filename
= "C:/myfile.txt";
Write(filename);
Read(filename);
return a.exec();
}
if (!mFile.
open(QFile::WriteOnly |
QFile::Text )){
cout << "could not write file.";
return;
}
cout << "hello world!!";
mFile.flush();
mFile.close();
}
cout << "could not open file for reading.";
return;
}
QDebug << mtext;
in << "hello world!!";
mFile.close();
}
#include <QtCore/QCoreApplication>
#include <QDebug>
#include <QString>
#include <QFile>
#include <QTextStream>
#include <iostream>
using namespace std;
void Write(QString filename);
void Read (QString filename);
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QString filename = "C:/myfile.txt";
Write(filename);
Read(filename);
return a.exec();
}
void Write(QString filename){
QFile mFile(filename);
if (!mFile.open(QFile::WriteOnly | QFile::Text )){
cout << "could not write file.";
return;
}
QTextStream out(&mFile);
cout << "hello world!!";
mFile.flush();
mFile.close();
}
void Read(QString filename){
QFile mFile(filename);
if (!mFile.open(QFile::ReadOnly | QFile::Text )){
cout << "could not open file for reading.";
return;
}
QTextStream in(&mFile);
QString mtext = in.readAll();
QDebug << mtext;
in << "hello world!!";
mFile.close();
}
To copy to clipboard, switch view to plain text mode
the error is showing up on line 53.
error: expected unqualified-id before '<<' token
Bookmarks