Hey there,

I'm new here, but not an absolut newbe with qt.
I have to ask here, because i didn't find any solution for my problem.

On My window I have a QTableWidget, wich I'm going to fill with checkboxes at runtime. I need signals for these checkboxes which contain the row count and the state from the checkbox signal toggled(bool state).

I tried the following, but it doesn't work. I actual don't understand the whole thing with QSignalMapper.


In the constructor I did:
Qt Code:
  1. checkboxMapper = new QSignalMapper(this);
To copy to clipboard, switch view to plain text mode 

My first try of the signal mapper:
Qt Code:
  1. ui->table->setRowCount(ui->table->rowCount()+1);
  2.  
  3. int index = ui->table->rowCount()-1;
  4.  
  5. QCheckBox *new_checkbox = new QCheckBox(this);
  6. new_checkbox->setChecked(true);
  7. connect(new_checkbox,SIGNAL(toggled(bool)),checkboxMapper,SLOT(map(bool)));
  8. checkboxMapper->setMapping(new_checkbox,(index,new_checkbox->isChecked()));
  9. connect(checkboxMapper,SIGNAL(mapped(int,bool)),this,SLOT(checkbox_toggled(int,bool)));
  10.  
  11. ui->table->setItem(index,0,new QTableWidgetItem("Some Stuff"));
  12. ui->table->setCellWidget(index,1,new_checkbox);
To copy to clipboard, switch view to plain text mode 

I hope my english is not too confusing and you could help me.

Kind regards