How to activate delegated item in qtreeview by custom shotcut.
Have anybody any ideas for realising custom edit key(not system F2) for editing item in qtreeview.
Re: How to activate delegated item in qtreeview by custom shotcut.
Well, if you subclcass the treeview and override its keyPressEvent, the you could start editing the selected item when you press the desired key by calling QTreeView::edit(const QModelIndex&).
You can get the selected index from the selection model.
Re: How to activate delegated item in qtreeview by custom shotcut.
If I have pushbutton, and want add action edit treeitem for it. Even F2 shotcut does not work:-(
Re: How to activate delegated item in qtreeview by custom shotcut.
So connect to button's signal, pick the current item and start editing? For example:
Code:
connect(button, SIGNAL(clicked()), this, SLOT(editTreeItem()));
void Window::editTreeItem()
{
if (index.isValid())
treeView->edit(index);
}
Re: How to activate delegated item in qtreeview by custom shotcut.
So you want to activate editing upon clicking the button or pressing the F2 key or both?
The most straightforward way is to connect the clicked() signal of the button to a custom slot in the view (or some other class), get the current index and call edit() on it. The shortcut cat be assigned to the pushbutton by using the shortcut property.
Re: How to activate delegated item in qtreeview by custom shotcut.
Yes, this solution really what i need.
Thanks