From a96d23a888611a7a6585875793d8178e5c184a17 Mon Sep 17 00:00:00 2001 From: duanshengchao <519970194@qq.com> Date: Sun, 27 Apr 2025 17:58:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B1=9E=E6=80=A7=E7=BC=96=E8=BE=91=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E5=8F=AA=E8=83=BD=E9=80=9A=E8=BF=87=E2=80=98=E5=B7=A6?= =?UTF-8?q?=E9=94=AE=E5=8F=8C=E5=87=BB=E2=80=99=E5=92=8C=E2=80=98F2?= =?UTF-8?q?=E2=80=99=E6=8C=89=E9=94=AE=E7=9A=84=E6=96=B9=E5=BC=8F=E8=A7=A6?= =?UTF-8?q?=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/attributeTableDelegate.h | 1 + source/attributeView.cpp | 1 + 2 files changed, 2 insertions(+) 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);