title: How to access elements returned from QSqlquerymodel set query
body: <p>I am having trouble understanding how i access the returned elements when i implement a QSqlQueryModel.</p>
  
  <p>I know that you can do
      QSqlQuery query;</p>
  
  <pre><code>query.prepare("select * from database");
  
  query.exec();
  
  query.next();
  
  qDebug() &lt;&lt; "value in 0 is " &lt;&lt; query.value(0).SomeFormat;
  </code></pre>
  
  <p>So i want to do something like that with QSqlQueryModel (apparently the better way to go).. where i set the query, then i can output the values to another lot of boxes i have.
  what i have so far is... </p>
  
  <pre><code>QSqlQuery selectAllUserFields;
  
  selectAllUserFields.prepare(QString("SELECT * from %1 WHERE %2=:firstName and %3=:lastName;")
                              .arg(dbase::c_userTableName)
                              .arg(dbase::c_colUserFirstName)
                              .arg(dbase::c_colUserSecondName));
  
  // finds the index of the current selection, so we can select the row
  QModelIndexList tableIndex = m_ui-&gt;populatedUserBox-&gt;selectionModel()-&gt;selection().indexes();
  
  
  QString firstName = tableIndex.at(0).data().toString();
  
  QString lastName = tableIndex.at(1).data().toString();
  
  QSqlQueryModel dbUsers;
  
  dbUsers.setQuery(selectAllUserFields);
  
  qDebug() &lt;&lt; "DEBUG: {temp} " &lt;&lt; dbUsers.record(0).value(0).toString();
  </code></pre>
  
  <p>I am beginnerish, so would appreciate a nudge in the right direction if anyone could assist.</p>
  
  <p>Thanks
  Grant</p>