Is there a way to see which objects have recently been deselected?
-
I have the following code which triggers every time itemSelection is changed
void TestConfig::on_tableWidget_Configs_itemSelectionChanged(){ //Determine if item is selected or not. //Make a list of all the crap that is selected. QModelIndexList selected = ui->tableWidget_Configs->selectionModel()->selectedRows(); for(int i = 0; i < ui->tableWidget_Configs->rowCount(); i++){ //Unchecks everything. This is a bad way of doing it. ui->tableWidget_Configs->item(i, 0)->setCheckState(Qt::Unchecked); qDebug() << "Line " << i << " unchecked"; } for(int i = 0; i < selected.size(); i++){ int r = selected.at(i).row(); qDebug() << selected.at(i).row(); ui->tableWidget_Configs->item(r, 0)->setCheckState(Qt::Checked); qDebug() << "Line " << r << " checked"; } }
I am wondering whether there is a function that would allow one to see which objects have recently been deselected so that I won't have to uncheck everything every time.
-
I have the following code which triggers every time itemSelection is changed
void TestConfig::on_tableWidget_Configs_itemSelectionChanged(){ //Determine if item is selected or not. //Make a list of all the crap that is selected. QModelIndexList selected = ui->tableWidget_Configs->selectionModel()->selectedRows(); for(int i = 0; i < ui->tableWidget_Configs->rowCount(); i++){ //Unchecks everything. This is a bad way of doing it. ui->tableWidget_Configs->item(i, 0)->setCheckState(Qt::Unchecked); qDebug() << "Line " << i << " unchecked"; } for(int i = 0; i < selected.size(); i++){ int r = selected.at(i).row(); qDebug() << selected.at(i).row(); ui->tableWidget_Configs->item(r, 0)->setCheckState(Qt::Checked); qDebug() << "Line " << r << " checked"; } }
I am wondering whether there is a function that would allow one to see which objects have recently been deselected so that I won't have to uncheck everything every time.
Also here you have to go through the QItemSelectionModel and it's selectionChanged() signal.