QTextStream reading line by line works only once
Solved
General and Desktop
-
Hi, so I have an issue with QTextStream.
I open the file, and read the lines I want to, but when I run it a second time, it doesn't do anything.Snippet of the line reading:
QFile *config = new QFile(Path); QTextStream in(config); config->open(QIODevice::ReadOnly | QIODevice::Text); in.readLine(); Slot1Name = in.readLine(); Slot1Text = in.readLine(); in.readLine(); Slot2Name = in.readLine(); Slot2Text = in.readLine(); in.readLine(); Slot3Name = in.readLine(); Slot3Text = in.readLine(); in.readLine(); Slot4Name = in.readLine(); Slot4Text = in.readLine(); in.readLine(); Slot5Name = in.readLine(); Slot5Text = in.readLine(); in.readLine(); Slot6Name = in.readLine(); Slot6Text = in.readLine(); in.readLine(); Slot7Name = in.readLine(); Slot7Text = in.readLine(); in.readLine(); Slot8Name = in.readLine(); Slot8Text = in.readLine(); in.readLine(); Slot9Name = in.readLine(); Slot9Text = in.readLine(); in.readLine(); Slot10Name = in.readLine(); Slot10Text = in.readLine(); in.readLine(); Slot11Name = in.readLine(); Slot11Text = in.readLine(); in.readLine(); Slot12Name = in.readLine(); Slot12Text = in.readLine(); in.readLine(); Slot13Name = in.readLine(); Slot13Text = in.readLine(); in.readLine(); Slot14Name = in.readLine(); Slot14Text = in.readLine(); in.readLine(); Slot15Name = in.readLine(); Slot15Text = in.readLine(); in.readLine(); Slot16Name = in.readLine(); Slot16Text = in.readLine(); in.readLine(); Slot17Name = in.readLine(); Slot17Text = in.readLine(); in.readLine(); Slot18Name = in.readLine(); Slot18Text = in.readLine(); in.readLine(); Slot19Name = in.readLine(); Slot19Text = in.readLine(); in.readLine(); Slot20Name = in.readLine(); Slot20Text = in.readLine(); config->close();
-
@Sucharek
Nobody can tell from this. You don't check the result fromopen()
. We don't know whetherPath
might have changed. Or the file on disk or its content. You could try your reads directly fromconfig
instead to rule out theQTextStream
being the issue.