diff --git a/include/attributeTableDelegate.h b/include/attributeTableDelegate.h index 097d693..b54b94b 100644 --- a/include/attributeTableDelegate.h +++ b/include/attributeTableDelegate.h @@ -52,6 +52,7 @@ public: explicit AttributeTableDelegate(QTableView* view, const QString& connection = "", QObject* parent = nullptr); ~AttributeTableDelegate(); + //bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) override; QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,const QModelIndex &index) const override; //void destroyEditor(QWidget* editor, const QModelIndex& index) const override; void setEditorData(QWidget *editor, const QModelIndex &index) const override; diff --git a/source/attributeView.cpp b/source/attributeView.cpp index 92c86de..f9529bf 100644 --- a/source/attributeView.cpp +++ b/source/attributeView.cpp @@ -20,6 +20,7 @@ AttributeView::AttributeView(const ModelAttributeGroup& modelAttributeGroup, QWi m_tableView->setStyleSheet("QTableView::item{padding-left:5px;} QTableView::item:selected{border:1px solid rgb(70,130,180);}"); m_tableView->verticalHeader()->setVisible(false); m_tableView->setTabKeyNavigation(false); //关闭tab键导航,对自定义Eidtor设置焦点时(比如lineEdit)会触发tab键,目前尚未清楚为什么 + m_tableView->setEditTriggers(QAbstractItemView::DoubleClicked | QAbstractItemView::EditKeyPressed); //禁用自动触发编辑的所有方式(自定义代理中按要求实现,这里是双击和空格) m_attributeTableModel = new AttributeTableModel(m_modelAttributeGroup, this, m_connection, m_attributeTable); m_tableView->setModel(m_attributeTableModel);