i am trying to select a data member from a model/view class, here a table view and add that particular data to an another table view. i can copy the data to another table view but only one selected data can add when i click the add button by using my code. can i add more data to table view by modifying the code or is there any other solution
void dcsinter::on_pushButton_clicked()
{
const QModelIndex index
= ui
->dirtableView
->selectionModel
()->currentIndex
();
QString selectedtext
= index.
data(Qt
::DisplayRole).
toString();
list << selectedtext ;
model2->setStringList(list);
ui->listtableView_2->setModel(model2);
ui->listtableView_2->setColumnWidth(0,600);
}
void dcsinter::on_pushButton_clicked()
{
const QModelIndex index = ui->dirtableView->selectionModel()->currentIndex();
QString selectedtext = index.data(Qt::DisplayRole).toString();
QStringListModel *model2 = new QStringListModel();
QStringList list;
list << selectedtext ;
model2->setStringList(list);
ui->listtableView_2->setModel(model2);
ui->listtableView_2->setColumnWidth(0,600);
}
To copy to clipboard, switch view to plain text mode
thank you
Bookmarks