"The writer appears to write correctly"
Appears to? It's writing a text file. Can you open the file in a text editor? Do the contents look correct?
"The writer appears to write correctly"
Appears to? It's writing a text file. Can you open the file in a text editor? Do the contents look correct?
Yes, it creates the file and looks fine. The two lines I included are from the file, in case someone could see something in the formatting that was wrong.
Sorry the headline of the thread is incorrect - I no longer get the out of range error - now it is just that there is no output. If the reader looks correct, it could be that the data is being read in but I have made a mistake with the output. When I run the output on it's own (using data that doesn't come from a text file but from main) output does work correctly.
What happens when you print out the extracted strings (fn, ln) as you process the file?
Thank you for your help. When I placed a qDebug << statement for the ln and ln variables, the firstname and lastname are output correctly. Do you think they are not being "added" properly to QList mylist?
Added after 4 minutes:
#include "contactlistreader.h"
#include <QFile>
#include <QTextStream>
#include <QStringList>
#include <QString>
#include <QDebug>
These are my include file in case they could be the problem. This has 5 .h class files - I'm going to try including them all just in case...
Last edited by april26; 8th April 2011 at 21:03.
You are hacking your way into problems:
1) you declare QTextStream out - and never use it...
2) the QTextStream is named out because you don't use it to read the file![]()
3) you don't check that the string fn (i assume that is a QString) is actually a file path/name that exist...
I don't see the problem, but my advice is: organize your code, don't just test in your actual project and then you don't know what's for testing and what's actual project, if you need a quick test to see how to write some small functionality - write it in a small separated project and test there.
And you use ContactList - is a hand-written container? or what is that? are you sure the bug is not there - use the debugger and you will see (or as SixDegrees said print to console as you read - and don't forget to check the file name)
Bookmarks