/** Called when switching between tabs * @param index :: The index of the new active tab */ void MantidMatrix::viewChanged(int index) { // get the previous view and selection model QTableView *prevView = (QTableView *)m_tabs->widget(m_PrevIndex); if (prevView) { QItemSelectionModel *oldSelModel = prevView->selectionModel(); QItemSelectionModel *selModel = activeView()->selectionModel(); // Copy the selection from the previous tab into the newly-activated one selModel->select(oldSelModel->selection(), QItemSelectionModel::Select); // Clear the selection on the now-hidden tab oldSelModel->clearSelection(); m_PrevIndex = index; // get the previous tab scrollbar positions int hValue = prevView->horizontalScrollBar()->value(); int vValue = prevView->verticalScrollBar()->value(); // to synchronize the views // set the previous view scrollbar positions to current view activeView()->horizontalScrollBar()->setValue(hValue); activeView()->verticalScrollBar()->setValue(vValue); } }