Qt Code:To copy to clipboard, switch view to plain text mode
Qt Code:To copy to clipboard, switch view to plain text mode
J-P Nurmi
As a side note: I suggest to use
Qt Code:
view->setCurrentIndex(view->model()->index(0, 0));To copy to clipboard, switch view to plain text mode
That way your code will work even when you finally decide you want to wrap your model in a QSortFilterProxyModel.
The compiler can not give you safety in the sense that a QModelIndex, a model and a view actually match (was the QModelIndex an index of the proxy or the source model again...).
Using view->model() etc makes your code improves maintainability by being more robust against such errors and model changes. And in my experience most views will sooner or later get a proxy round their model.
HTH
Bookmarks