Single selection of QModelIndex is alright for me now. However, I'm wondering how can I use QAbstractItemView::selectedIndexes () const [virtual protected] to get the list of multiple selected cells' QModelIndexes? Should I should use QAbstractItemDelegate?
E.g. multiple selection cells using Ctrl - Left mouse click / Shift / Left mouse click and drag to select cells?
Last edited by sheeeng; 27th July 2010 at 09:46.
You can access selected indexes through QAbstractItemView::selectionModel().
Qt Code:
tableView->selectionModel()->selectedIndexes();To copy to clipboard, switch view to plain text mode
Last edited by saa7_go; 27th July 2010 at 13:35. Reason: updated contents
Maybe, yes.... I don't understand with "after some event from MainWindow".
For example, if you have a pushbutton, you connect it's clicked() signal to your pusbutton_clicked() slot, then in your pushbutton_clicked() function you called selectedIndexes().
Last edited by saa7_go; 27th July 2010 at 15:02. Reason: updated contents
I did tried to use the code below to make left-click drag and multiple selection of cells. It works with multiple selection. However, I cannot make entered() and clicked() mutually exclusive to each other for a cell. It triggers double events called when clicked and the reverted the value. Any other approaches?
Also, how can I paint a "focus" rectangle upon mouse hover a QTableView's cell?Qt Code:
connect( tableView, SIGNAL(entered(const QModelIndex &) ), this, SLOT( setOnOff(const QModelIndex &) ) ); connect( tableView, SIGNAL(clicked(const QModelIndex &) ), this, SLOT( setOnOff(const QModelIndex &) ) );To copy to clipboard, switch view to plain text mode
Bookmarks