修复通过自定义控件编辑属性信息后tableview丢失焦点问题
This commit is contained in:
parent
627646e31f
commit
23da60a235
|
|
@ -198,10 +198,14 @@ QWidget* AttributeTableDelegate::createEditor(QWidget *parent, const QStyleOptio
|
|||
//判断放在setModelData函数中,因为那里会先进行是否做内容改变的判断
|
||||
emit const_cast<AttributeTableDelegate*>(this)->commitData(textEditor);
|
||||
emit const_cast<AttributeTableDelegate*>(this)->closeEditor(textEditor, QAbstractItemDelegate::NoHint);
|
||||
if(m_tableView)
|
||||
m_tableView->setFocus();
|
||||
});
|
||||
connect(textEditor, &TextEditWidget::cancle, this, [=]{
|
||||
//createEditor为const成员函数,而closeEditor是QAbstractItemDelegate的非const信号,在const成员函数中不能直接调用,需要转换为非const指针
|
||||
emit const_cast<AttributeTableDelegate*>(this)->closeEditor(textEditor, QAbstractItemDelegate::NoHint);
|
||||
if(m_tableView)
|
||||
m_tableView->setFocus();
|
||||
});
|
||||
//延迟获取焦点,防止可能因渲染未完成失效
|
||||
QTimer::singleShot(10, this, [textEditor]() {
|
||||
|
|
@ -215,9 +219,13 @@ QWidget* AttributeTableDelegate::createEditor(QWidget *parent, const QStyleOptio
|
|||
connect(textEditor, &TextEditWidget::confirm, this, [=]{
|
||||
emit const_cast<AttributeTableDelegate*>(this)->commitData(textEditor);
|
||||
emit const_cast<AttributeTableDelegate*>(this)->closeEditor(textEditor, QAbstractItemDelegate::NoHint);
|
||||
if(m_tableView)
|
||||
m_tableView->setFocus();
|
||||
});
|
||||
connect(textEditor, &TextEditWidget::cancle, this, [=]{
|
||||
emit const_cast<AttributeTableDelegate*>(this)->closeEditor(textEditor, QAbstractItemDelegate::NoHint);
|
||||
if(m_tableView)
|
||||
m_tableView->setFocus();
|
||||
});
|
||||
//延迟获取焦点,防止可能因渲染未完成失效
|
||||
QTimer::singleShot(10, this, [textEditor]() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue