I've checked if the location of the file was correct and it was so I have no idea why my program is not working. I have literally been looking at it for a few hours but I still cant find out whats wrong. I would really appreciate any input.
Text in text file: Bob Janurary 1 2000 Math 7A 5 41 7 9 8 8 9
relevant code:
void MainWindow::on_pushButton_clicked()
{
QString name, month, subject, level;
int day, year, apages, total, one, two, three, four, five, six, seven, eight, nine, ten;
QFile file("C:/Users/brandan/Desktop/GUIPrograms/Kumon.txt");
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
QTextStream stream(&file);
QString line;
do
{
qDebug() << "test";
line = stream.readLine();
qDebug() << line;
} while(!line.isNull());
}
}
You are checking if the file is opened correctly with
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
so your code is executed only if the file is NOT opened correctly. Use
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {