Unsolved Refreshing QTableView selection manually
-
Hello,
I have a probleme with a qTableview.
I have two widgets, a qCustomPlot and a qTableView between wich selections signals are sent.
For the uses of my application, i was forced to blockSignal on my SelectionModel's TableView and modify the selection manually.
But, when i select my indexes, if there is no scroll, the olds selected lines doesn't deselect until user get focus on qTableView or until the QTableView is resized/scrolled.
I tried update(), repaint() and show() on mys tableView but nothing changed! :/Here is the code:
void OSGM::onGraphSelectionChanged(int index) { auto selectionModel = m_TableView.selectionModel(); QItemSelection selection; selectionModel->blockSignals(true); // if it's a selection if (index != OSGEH::ELEMENT_DESELECTED) { // create the selection manually auto keys = m_TabRectMap.keys(index); for (auto key : keys) { auto row = m_TableView.model()->index(key, 0); selection.append(QItemSelectionRange(row, row)); } } selectionModel->select(selection, QItemSelectionModel::Current | QItemSelectionModel::Rows); selectionModel->blockSignals(false); if (selection.size() != 0) { // scroll qtableview to the first item m_TableView.scrollTo(selection.at(0).bottomRight(),QAbstractItemView::PositionAtTop); } m_TableView.show(); }
-
Hi and welcome to devnet,
Why do you need to call blockSignals ?