title: Reading a random line from a txt file, then trim it in QT SDK
body: <p>I'd like to ask your help with my little school project.
  The task is to determine a person's gender (using 2 radio buttons) and then pick a random Japanese family name and male/female middlename. And there's the rest of the task, but it's nothing compared to this part :( 
  Thing is, i have managed to make the 3 .txt files (familynames.txt, malemiddlenames.txt and femalemiddlenames.txt) look like the following: 
  1,Akiro
  2,Sakura
  3,etc...</p>
  
  <p>What i'd like to do is create a random number, and read the lines until it arrives to the line with the same number as my random number, then cut the number and the comma off, and display the name on the corresponding label. So far this is what i've got:</p>
  
  <pre><code>void MainWindow::famname()
  {
      QString familyname;
      int famrand =qrand() % 76;
      ui-&gt;label_2-&gt;setText(QString::number(famrand));
      int i = 1;
  
      QFile famfile("C:\Users\Ryseth\gyakorlas\_familynames.txt");
      QTextStream in(&amp;famfile);
      if(famfile.open(QIODevice::ReadOnly)){
  
          while (!in.atEnd()) {
               QString line = in.readLine();
               i++;
               if(i==famrand){
                   QStringList line2 =line.split(',');
                   familyname = line2.at(0);
                   ui-&gt;label_2-&gt;setText(QString::number(famrand)+" "+QString::number(i));
                   ui-&gt;FamilyLabel-&gt;setText(familyname);
               }//IF
           }//WHILE
      }//IF
           famfile.close();
  }//NGEN
  </code></pre>
  
  <p>If any of you could think of some sort of solution or if you have ANY suggestions, please don't hasitate to share it with me :D</p>
  
  <p>Thank you, and have a nice day/night : Ruben</p>