Hello,
I try to detect cases where there is a selection or none, on a QTableView which allows single rows selection.
What's wrong? Code below doesn't fail, but I don't get the popups "xLogWarning()" calls should produce...
I'm also wondering about the model giving me its value for selected row and column of my choice...
I also read this topic: http://www.qtcentre.org/threads/1046...t-selected-row
Thanks for helping.
m_tableView = new QTableView();
m_tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
m_tableView->setSelectionMode(QAbstractItemView::SingleSelection);
To copy to clipboard, switch view to plain text mode
// Get selected image
if(!selectedModel->hasSelection()) {
xLogWarning(tr("No image selected"));
return;
}
xLogWarning(tr("There is an image selected"));
QModelIndexList selection = selectedModel->selectedIndexes();
xLogWarning(tr("selected row: %1").arg(selection[0].row()));
xLogWarning(tr("Selected image: %1").arg(m_model.getObjectIdAt(selection[0].row())));
// Get selected image
QItemSelectionModel* selectedModel = m_tableView->selectionModel();
if(!selectedModel->hasSelection()) {
xLogWarning(tr("No image selected"));
return;
}
xLogWarning(tr("There is an image selected"));
QModelIndexList selection = selectedModel->selectedIndexes();
xLogWarning(tr("selected row: %1").arg(selection[0].row()));
xLogWarning(tr("Selected image: %1").arg(m_model.getObjectIdAt(selection[0].row())));
To copy to clipboard, switch view to plain text mode
Bookmarks