I tried to delete a selected row of a QTreeView with an event. This is the 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. But the problem is that the selected row will not be deleted. In "return remove" i get a "false".
why you do not used CurrentIndex ?
bool remove = examplemodel->model()->removeRow(row, select);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.