给位大佬,请问为什么如下的代码中自定义表格QTableView删除失败呢?
从QAbstractTableModel派生出子类myTableModel自定表格数据模型和从QTableView派生出子类myTableView。在myTableView选中后,进行删除失败操作,具体代码如下:
m_pMenu = new QMenu(this);
m_pActOpen = new QAction(MENU_OPEN_INFO, this);
m_pActDel = new QAction(MENU_REMOVE_INFO, this);
m_pMenu->addAction(m_pActOpen);
m_pMenu->addAction(m_pActDel);
connect(m_pActDel, &QAction::triggered, this, &myTableView::slotActionDelFun);
void myTableView::slotActionDelFun()
{
qDebug()<<"del="<<this->currentIndex().row();
m_myModel->removeRow(this->currentIndex().row());
}
选中后,点击右键菜单中的删除,结果表格里,还是无法删除,难道removeRow这个还要在myTableModel重新实现吗?请各位大佬指点一下,不胜感激!!