Ok, i have QAbstractItemMode object with 4 columns and N rows.
i need get data from column ID and current double-clicked row
Ok, i have QAbstractItemMode object with 4 columns and N rows.
i need get data from column ID and current double-clicked row
You need to concentrate on the view, not the model. I assume it is a QTableView. The QAbstractItemView::doubleClicked() signal will give you the model index that was clicked on. You now have the QModelIndex::row() and can easily build another QModelIndex with the column set to 0 ( or whichever model column is the ID) using QModelIndex::sibling() or some other method.
Normally double-clicking would put the affected cells into edit mode. Is the model editable or not?
Last edited by ChrisW67; 27th January 2011 at 00:34.
I'm not sure if I understand your question but in case you are looking for a way to find the currently selected row(s), you'll need to look in the view object displaying the data rather than the model itself.
QAbstractItemView::selectedIndexes ()
QAbstractItemView::selectionModel ()
Editmode is off. One click whole row is selected.
no. i will use QAbstractItemModel because it's necessary for my project. Any ideas?You need to concentrate on the view, not the model. I assume it is a QTableView.
You must be using some sort of view, since QAbstractItemModel doesn't display anything itself. What ChrisW67 meant was that, to judge from your uploaded image, your code seems to use QTableView to present the data.
Can you post the part of your code where you instantiate your model subclass (possibly in MainWindow or something similar).
Oh, sorry. I use QTreeView for display data
proxyModel = new QSortFilterProxyModel;
proxyModel->setDynamicSortFilter(true);
proxyView = new QTreeView;
proxyView->setRootIsDecorated(false);
proxyView->setAlternatingRowColors(true);
proxyView->setModel(proxyModel);
proxyView->setSortingEnabled(true);
proxyView->setSelectionMode(QAbstractItemView::SingleSelecti on);
proxyView->setSelectionBehavior(QAbstractItemView::SelectRow s);
proxyView->setEditTriggers(QAbstractItemView::NoEditTriggers );
oh, qtreeview has slot doubleclicked. think with using that slot my problem must be solved.
Good. Would you mind editing your original post and uploading the image to this forum so that it doesn't go missing and we are not using someone else's bandwidth?
have some question: double click wasn't problem. But by double click on qtreeview object i can get qmodelindex - current row and current column. But i need data from current row and column ID only.
and all is work)Qt Code:
proxyView->currentIndex().sibling(proxyView->currentIndex().row(),0).data().toString();To copy to clipboard, switch view to plain text mode
Bookmarks