Hello,
I'm trying to get the data from the first cell of an IndexList that gets its data from a selection model, which in turn is called to pass said data into a QVariant variable. However, I'm unsure on how to get the first (or whichever) data item from said list. Instead, the data from the currently selected cell is transfered to my QVariant variable, which leads to problems.
So say I have a row of items: NAME | DATE | NOTES
And I want to edit this row (which gets its data from a linked list), so I click on the NOTES cell (whichever one), click my edit button that will get the data ASSOCIATED WITH THE "NAME" data from said linked list, change tabs, and present said data for editing. So basically, if I click on the NOTES or DATE cell, I want to be able to get data from their respective NAME cell.
I was trying to do this (amongst other attempts), but miserably:
selectionModel = ui->taskView->selectionModel();
QModelIndexList editIndex = selectionModel->selectedRows();
if (!editIndex.isEmpty()) {
QMessageBox::information(this, tr
("Prepare to Edit!"), tr
("Checkpoint 1"));
target = (editIndex.first()).data(); //Should get the name data
QMessageBox::information(this, tr
("Prepare to Edit!"), tr
("\"%1\" - Checkpoint 2").
arg(target.
toString()));
tlink.find(target.toString(), name);
QMessageBox::information(this, tr
("Prepare to Edit!"), tr
("Checkpoint 3"));
QMessageBox::information(this, tr
("Prepare to Edit!"), tr
("\"%1\"'s task will now be edited.").
arg(name
));
}
QVariant target;
selectionModel = ui->taskView->selectionModel();
QModelIndexList editIndex = selectionModel->selectedRows();
if (!editIndex.isEmpty()) {
QMessageBox::information(this, tr("Prepare to Edit!"), tr("Checkpoint 1"));
target = (editIndex.first()).data(); //Should get the name data
QMessageBox::information(this, tr("Prepare to Edit!"), tr("\"%1\" - Checkpoint 2").arg(target.toString()));
tlink.find(target.toString(), name);
QMessageBox::information(this, tr("Prepare to Edit!"), tr("Checkpoint 3"));
QMessageBox::information(this, tr("Prepare to Edit!"), tr("\"%1\"'s task will now be edited.").arg(name));
}
To copy to clipboard, switch view to plain text mode
Thanks for the help!
- Bona
Bookmarks