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):
printviewdialog *print = new printviewdialog;
print->exec();
//Declaring an item selection which we will use to see which row the user has selected
QList<int> rows;
foreach
( const QModelIndex & index, selection.
indexes() ) { rows.append( index.row() );
}
qSort( rows );
for( int i = rows.count() - 1; i >= 0; i -= 1 ) {
QString name
= model
->record
(i
).
value("name").
toString();
print->textEdit->append(name);
}
if (print->Accepted) {
print->textEdit->print(print->printer);
}
printviewdialog *print = new printviewdialog;
print->exec();
//Declaring an item selection which we will use to see which row the user has selected
QItemSelection selection = ui->View->selectionModel()->selection();
QList<int> rows;
foreach ( const QModelIndex & index, selection.indexes() ) {
rows.append( index.row() );
}
qSort( rows );
for( int i = rows.count() - 1; i >= 0; i -= 1 ) {
QString name = model->record(i).value("name").toString();
print->textEdit->append(name);
}
if (print->Accepted) {
print->textEdit->print(print->printer);
}
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
Bookmarks