Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How can exclude the file extension when i rename the item in QTreeView

How can exclude the file extension when i rename the item in QTreeView

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 333 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    WhichOneCanIDo
    wrote on last edited by WhichOneCanIDo
    #1

    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 code

    this->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.

    jsulmJ 1 Reply Last reply
    0
    • W WhichOneCanIDo

      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 code

      this->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.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @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.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      W 1 Reply Last reply
      0
      • jsulmJ jsulm

        @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.

        W Offline
        W Offline
        WhichOneCanIDo
        wrote on last edited by
        #3

        i have found one related answer
        setEditorData() do selectall in qt src
        so ,when i inheirt by delegate,it cnat not be changed
        see in link text
        @jsulm

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved