我在QTableWidet中添加了一个QComboBox
QComboBox *ziduan = new QComboBox;
tableWidget->setCellWidget(rowNum,1,ziduan);
我想在currentIndexChanged信号中获取comboBox所在的行,列。
int col = 1;
int row=1;
QSignalMapper* signalMapper = new QSignalMapper(this);
connect(ziduan, SIGNAL(currentIndexChanged(int)), signalMapper, SLOT(map()));
signalMapper->setMapping(ziduan, QString("%1-%2").arg(rowNum).arg(col));
connect(signalMapper, SIGNAL(mapped(const QString &)),this, SIGNAL(changeZiduan(const QString &)));
void sqlGenerator::changeZiduan(const QString &position)
{
QStringList coordinates = position.split("-");
int row = coordinates[0].toInt();
int col = coordinates[1].toInt();
}
这样写不起作用,改变index的时候,并没有响应changZiduan函数。
哪位高手能帮忙解决一下。只要能获取comboBox所在的行,列。