简体   繁体   English

如何在 QTreeView 中删除选定的行?

[英]How to, inside a QTreeView, delete a selected row?

I tried to delete a selected row of a QTreeView with an event.我试图删除带有事件的 QTreeView 的选定行。 This is the function:这是 function:

bool TargetEventFilter::deleteselect(bool delete)
{
    auto select= examplemodel->selectionModel()->currentIndex();
    auto parent= select.parent();
    int row= select.row();
    bool remove = examplemodel->model()->removeRow(row, parent);
    return remove ;
}

So my problem is: The event is working (tried with the debugger).The Parent and the indext is always right.所以我的问题是:事件正在运行(使用调试器尝试过)。Parent 和 indext 总是正确的。 But the problem is that the selected row will not be deleted.但问题是所选行不会被删除。 In "return remove" i get a "false".在“return remove”中,我得到一个“false”。

why you do not used CurrentIndex ?为什么你不使用CurrentIndex

 bool remove = examplemodel->model()->removeRow(row, select);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM