PDA

View Full Version : QTreeView edit() not working.



billw
20th August 2010, 18:26
I have made a customised directory model and plugged it into a QTreeView. The standard edit works fine when triggered by the user (pressing F2 or clicking on an already selected directory). But I can't get seem to trigger it programmatically. I have added a "New Folder" button, and when this is pressed a folder called "New Folder" is added under the currently selected folder. I want to immediately open an edit box for this new folder, but just cannot get Qt to do it. At the moment I am doing the following:
creating the new directory on disk,
then recreating the model object from scratch and assigning it to the view,
then expanding out the hierarchy to the new folder,
focusing the QTreeView,
selecting the new folder,
calling QTreeView->edit(currentIndex());

Any ideas what is going on? The new folder gets selected correctly, but doesn't losing focus when edit is called, like focus is moving to the new edit widget. But the widget never appears.

edit/
Okay I found the problem, and it was due to the fact that I was using a thread to check for changes to the directory structure and this was causing the model to be recreated immediately.