如图,怎么获取combox所在的行,点击combox时table的currentrow不改变,只有点击非combox的单元格才能通过currentrow获取所在行。
------解决思路----------------------
方法1
void MyComboBox ::focusInEvent ( QFocusEvent * event )
{
QModelIndex idx = table->indexAt(pos());
table->setCurrentIndex(idx);
}
方法2
combox->installEventFilter(table);
bool table::eventFilter(QObject *obj, QEvent *event)
{
if (event->type() == QEvent::FocusIn) {
QComboBox *combox = qobject_cast<QComboBox *>(obj);
if(combox )
{
QModelIndex idx = indexAt(combox->pos());
setCurrentIndex(idx);
}
return true;
} else {
// standard event processing
return QObject::eventFilter(obj, event);
}
}