Have anybody any ideas for realising custom edit key(not system F2) for editing item in qtreeview.
Have anybody any ideas for realising custom edit key(not system F2) for editing item in qtreeview.
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.
If I have pushbutton, and want add action edit treeitem for it. Even F2 shotcut does not work:-(
So connect to button's signal, pick the current item and start editing? For example:
Qt Code:
connect(button, SIGNAL(clicked()), this, SLOT(editTreeItem())); void Window::editTreeItem() { if (index.isValid()) treeView->edit(index); }To copy to clipboard, switch view to plain text mode
J-P Nurmi
visor_ua (6th December 2007)
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.
Yes, this solution really what i need.
Thanks
Bookmarks