属性编辑改为只能通过‘左键双击’和‘F2’按键的方式触发

This commit is contained in:
duanshengchao 2025-04-27 17:58:59 +08:00
parent 6b45c6e222
commit a96d23a888
2 changed files with 2 additions and 0 deletions

View File

@ -52,6 +52,7 @@ public:
explicit AttributeTableDelegate(QTableView* view, const QString& connection = "", QObject* parent = nullptr); explicit AttributeTableDelegate(QTableView* view, const QString& connection = "", QObject* parent = nullptr);
~AttributeTableDelegate(); ~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; QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,const QModelIndex &index) const override;
//void destroyEditor(QWidget* editor, const QModelIndex& index) const override; //void destroyEditor(QWidget* editor, const QModelIndex& index) const override;
void setEditorData(QWidget *editor, const QModelIndex &index) const override; void setEditorData(QWidget *editor, const QModelIndex &index) const override;

View File

@ -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->setStyleSheet("QTableView::item{padding-left:5px;} QTableView::item:selected{border:1px solid rgb(70,130,180);}");
m_tableView->verticalHeader()->setVisible(false); m_tableView->verticalHeader()->setVisible(false);
m_tableView->setTabKeyNavigation(false); //关闭tab键导航对自定义Eidtor设置焦点时(比如lineEdit)会触发tab键目前尚未清楚为什么 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_attributeTableModel = new AttributeTableModel(m_modelAttributeGroup, this, m_connection, m_attributeTable);
m_tableView->setModel(m_attributeTableModel); m_tableView->setModel(m_attributeTableModel);