PDA

View Full Version : how to use the void QAbstractItemView::clearSelection()



tomorrow
29th November 2013, 21:36
I want to have a button which when it is clicked it clear the selection for QListWidget items
I searched and people were suggesting to use
void QAbstractItemView::clearSelection()
any suggestion on how to use this ?


void MainWindow::on_Button_clear_all_clicked()
{
//
}

ChrisW67
29th November 2013, 22:47
any suggestion on how to use this ?


void MainWindow::on_Button_clear_all_clicked()
{
ui->listWidget->clearSelection();
}

QListWidget is a QAbstractItemView. You could connect the signal direct to the QListWidget slot.

As i understand it this will delete the content of the selected cells. If you mean to unselect all the cells then you should look at the methods on the listWidget->selectionModel() object.