quizzmaster
14th September 2014, 00:43
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:
checkboxMapper = new QSignalMapper(this);
My first try of the signal mapper:
ui->table->setRowCount(ui->table->rowCount()+1);
int index = ui->table->rowCount()-1;
QCheckBox *new_checkbox = new QCheckBox(this);
new_checkbox->setChecked(true);
connect(new_checkbox,SIGNAL(toggled(bool)),checkbo xMapper,SLOT(map(bool)));
checkboxMapper->setMapping(new_checkbox,(index,new_checkbox->isChecked()));
connect(checkboxMapper,SIGNAL(mapped(int,bool)),th is,SLOT(checkbox_toggled(int,bool)));
ui->table->setItem(index,0,new QTableWidgetItem("Some Stuff"));
ui->table->setCellWidget(index,1,new_checkbox);
I hope my english is not too confusing and you could help me.
Kind regards
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:
checkboxMapper = new QSignalMapper(this);
My first try of the signal mapper:
ui->table->setRowCount(ui->table->rowCount()+1);
int index = ui->table->rowCount()-1;
QCheckBox *new_checkbox = new QCheckBox(this);
new_checkbox->setChecked(true);
connect(new_checkbox,SIGNAL(toggled(bool)),checkbo xMapper,SLOT(map(bool)));
checkboxMapper->setMapping(new_checkbox,(index,new_checkbox->isChecked()));
connect(checkboxMapper,SIGNAL(mapped(int,bool)),th is,SLOT(checkbox_toggled(int,bool)));
ui->table->setItem(index,0,new QTableWidgetItem("Some Stuff"));
ui->table->setCellWidget(index,1,new_checkbox);
I hope my english is not too confusing and you could help me.
Kind regards