PDA

View Full Version : [SOLVED] regarding QSignalMapper and QComBox in QTableWidget



xeroblast
7th December 2010, 08:28
hi,

this is my code to display a QComboBox in a QTableWidget and using QSignalMapper to re-emit the signal but the output is Object::connect: No such signal QComboBox::currentIndexChanged()



QSignalMapper* signalMapper = new QSignalMapper(this);
QString val = tableUsers->item(y, x)->text();
QComboBox* dropdownPosition = new QComboBox();
QSqlQuery query;
query.exec("SELECT * FROM position");
int i = 0;
while (query.next()) {
dropdownPosition->addItem(query.value(1).toString());
if (val == query.value(1).toString()) dropdownPosition->setCurrentIndex(i);
i++;
}
query.clear();
tableUsers->setCellWidget(y, x, dropdownPosition);
connect(dropdownPosition, SIGNAL(currentIndexChanged()), signalMapper, SLOT(map()));
signalMapper->setMapping(dropdownPosition, QString("%1-%2").arg(y).arg(x));
connect(signalMapper, SIGNAL(mapped(const QString &)), this, SLOT(editUserPosition()));


am i doing it right? or there is something missing in my code? thanx for the help..

Lykurg
7th December 2010, 08:56
It is not clear why you use a signal mapper but anyway the warning is because there is no signal called currentIndexChanged()! You mean currentIndexChanged(int) or currentIndexChanged(const QString&), don't you?

xeroblast
7th December 2010, 09:19
thanx. and you were right. i just have to add the parameter...

i use the signal mapper coz every time the user double clicks in QTableWidget position column, a QComboBox appears but the QComboBox signal cant emit its signal to the given function for editing the value.

thanx a lot...