QString val
= tableUsers
->item
(y, x
)->text
();
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
()));
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()));
To copy to clipboard, switch view to plain text mode
Bookmarks