I have a bunch of qComboboxes in a table.
So that I know which one was triggered I remap the signal to encode the table cell location (as described in http://stackoverflow.com/questions/1332110/selecting-qcombobox-in-qtablewidget)
(Why Qt doesn't just send the cell activated signal first so you can use the same currentRow/COlumn mechanism as any other cell edit I don't know)
But this removes all knowledge of the original sender widget.
Calling "QComboBox* combo = (QComboBox* )sender()" in the slot fails, presumably because sender() is now the QSignalMapper?
I can use the encoded row/column to lookup the QCombobox in the Tablewidget but that seems wrong.
Is there a more correct way to do it?
eg
// in table creator
_signalMapper = new QSignalMapper(this);
// for each cell
QComboBox* combo = new QComboBox();
connect(combo, SIGNAL(currentIndexChanged(int)), _signalMapper, SLOT(map()));
_signalMapper->setMapping(combo, row);
// and finally
connect(_signalMapper, SIGNAL(mapped(int)),this, SLOT(changedType(int)));
// slot
void myDlg::changedType(int row)
{
QComboBox* combo = (QComboBox* )sender(); // this doesn't work !!
}
EDIT: Added for future search, there is a new book "Advanced Qt Programming" by Mark Summerfield that explains how to do this sort of thing: