Solved How can exclude the file extension when i rename the item in QTreeView
-
Now the action to rename will choose all the text i wanted to change ,but i want to keep the file extension used to be. I don't want the user change the extension when they don't want to that.
The result i wanted is that the blue bar will not contain the extension name, just like the file renaming in the Windows.
now i used the codethis->edit(indexList.at(0));
which just the api of QT.
So how can i solve the problem. thanks.new:
i found that i can use the delgate to replace the default editor with qlineedit .
but it still cant solve the problem because it selectAll when i edit ,i cant change selection by setSelection.
what can i do next. -
@WhichOneCanIDo said in How can exclude the file extension when i rename the item in QTreeView:
i cant change selection by setSelection
Sure, you can.
First search for the file extension. See the indexOf() methods in QString.. Then you know where the file extension starts and you can set the selection as needed. -