void MainWindow::bodyclicked(int bodyIndex) { indexSelected = bodyIndex; QListView * objectList = findChild<QListView*>(QString("objectList")); if(indexSelected == -1) //used clicked on empty space { objectList->clearSelection(); } else { QModelIndex qIndex = objectListSource->index(indexSelected); objectList->setCurrentIndex(qIndex); } }
/** * @brief MainWindow::setDocumentModel * * Will be called whe a new q2d::Project is created, to link the projects * document model with the appropriate list view in the UI. * @param model */ void MainWindow::slot_setDocumentModel(QStandardItemModel* model) { // close all tabs related to the old model m_ui->schematicsTabWidget->clear(); QListView* documentView = m_ui->documentListView; documentView->clearSelection(); QAbstractItemModel* oldModel = documentView->model(); m_ui->documentListView->setModel(model); if (oldModel != nullptr) { oldModel->disconnect(); oldModel->deleteLater(); } }
void FileDialog::clearSelection() { QListView *view = findChild<QListView*>(); Q_ASSERT( view ); view->clearSelection(); }