Hi guys,

Have a bit of a problem here, the following code doesn't work properly (it doesn't copy the value of certain fields of a user-selected record unto a QTextEdit):

Qt Code:
  1. printviewdialog *print = new printviewdialog;
  2. print->exec();
  3. //Declaring an item selection which we will use to see which row the user has selected
  4. QItemSelection selection = ui->View->selectionModel()->selection();
  5. QList<int> rows;
  6. foreach ( const QModelIndex & index, selection.indexes() ) {
  7. rows.append( index.row() );
  8. }
  9. qSort( rows );
  10. for( int i = rows.count() - 1; i >= 0; i -= 1 ) {
  11. QString name = model->record(i).value("name").toString();
  12. print->textEdit->append(name);
  13. }
  14. if (print->Accepted) {
  15. print->textEdit->print(print->printer);
  16. }
To copy to clipboard, switch view to plain text mode 

What am I doing wrong? Code samples would be largely appreciated.

Thanks in advance,

Nefastious