title: Reading, writing and searching through text files with Qt
body: <p>I'm stuck with Qt (again) and I'm trying to read text from a text file. Here is what the text file contains:</p>
  
  <pre><code>1001 James Bark
  1002 Jeremy Parker
  1003 Seinfeld Parker
  1004 Sigfried FonStein
  1005 Rabbun Hassan
  1006 Jenniffer Jones
  1007 Agent Smith
  1008 Mister Anderson
  </code></pre>
  
  <p>Don't ask where the names came from. I need to be able to index this file and add it to a table. The table, as of now, looks like this:</p>
  
  <pre><code>|--------------------------------|
  |          |First Name|Last Name | 
  |--------------------------------|
  |1001      |          |          |  
  |--------------------------------| 
  |          |          |          |
  |--------------------------------|      
  |          |          |          |
  |--------------------------------|      
  |          |          |          |      
  |--------------------------------|
  </code></pre>
  
  <p>But it needs to look like this </p>
  
  <pre><code>    |--------------------------------|
      |          |First Name|Last Name | 
      |--------------------------------|
      |1001      |James     |Bark      |  
      |--------------------------------| 
      |1002      |Jeremy    |Parker    |
      |--------------------------------|      
      |1003      |Seinfeld  |FonStein  |
      |--------------------------------|      
      |1004      |Rabbun    |Hassan    |      
      |--------------------------------|
  </code></pre>
  
  <p>The table part and putting the items in is not a problem. The problem lies in reading a text file that is formatted like the example at the top. Also, I don't need it to be formatted like that. I could have 3 different text files with ID, Fname, and Lname seperated in those files. This would be a hassle, but if I have to do this I will. </p>
  
  <p>So my question is how the hell do I index through this file and get these values?</p>
  
  <p>Here's a function:</p>
  
  <pre><code>Function(){
      QString fileName = "C:\\Users\\Gabe\\SeniorProj\\Students.txt";
      QFile mFile(fileName);
  
      if(!mFile.open(QFile::ReadOnly | QFile::Text)){
          qDebug() &lt;&lt; "Could not open file for reading";
          return;
      }
  
      QTextStream in(&amp;mFile);
      QString mText = in.readAll();
  
      mFile.flush();
      mFile.close();
      }
  </code></pre>
  
  <p>This code I got from some tutorial somewhere. Everything works, I've checked if I can access the file, and all is good. But what to do with it... I have a string equal to all of the text. That's not very useful. So I tried stuff I used in c++, like <code>mFile.nextInt();</code> Well that function doesn't exist!!! </p>
  
  <p>How do I search through a text file for specific things in Qt?</p>