次のコードを使用して、QTreeView コンポーネントで行全体を選択しようとしています。
const QModelIndex topLeft = model->index(0, 0);
const QModelIndex bottomRight = model->index(model->rowCount(), model->columnCount());
ui->hidDescriptorView->selectionModel()->selection().select(topLeft, bottomRight);
私は少し無知で、 const_cast などを使用して選択を機能させようと探し回っていましたが、コンパイラーは次のエラーを出しています:
/.../mainwindow.cpp:93: error: member function 'select' not viable: 'this' argument has type 'const QItemSelection', but function is not marked const
ui->hidDescriptorView->selectionModel()->selection().select(topLeft, bottomRight);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
私は選択を行うことができた前のビットから来ていますが、単一のセルしか選択されないため、ユーザーがクリックしたかのように、行全体が適切に選択されるように上記を試しています.
どんな助けでも大歓迎です!