Results 1 to 3 of 3

Thread: List View with renamable items?

  1. #1
    Join Date
    May 2010
    Posts
    10
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default List View with renamable items?

    I'm trying to figure out how to create a list view (either a plain QListView or a QListViewWidget, I suppose) which allowss the user to edit the item names.

    For example, the list has three items, the user double-clicks (or, more appropriately, clicks twice) on an item and the text for that item turns into a text box, which the user can then edit. When the user presses enter or changes focus from the box, the text box turns back into plain text with the new name.

    Ideally, when we first add an item to the list, it will start out in "rename mode" so that the user can give that item a name. So the user clicks the "add [item]" button, a new item appears on the list in "rename mode", they enter in the item's name, hit enter, and then new item finally turns into regular text with the user's name.

    Google and the forum's search function are of no help here; searching "qlistview rename" doesn't return what I'm looking for. It does look like QT3 supported this more easily, but I'm using 4.6. I'm a QT newbie, though, so I may very well be missing something obvious.

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: List View with renamable items?

    You need to make the item editable. And Qt will invoke editing on double click or based on edit triggers.

  3. The following user says thank you to aamer4yu for this useful post:

    MattT (17th July 2010)

  4. #3
    Join Date
    May 2010
    Posts
    10
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: List View with renamable items?

    Awesome, thanks, that was exactly the hint I needed to find what I needed for figuring out what I needed. Knowing to use the keyword "edit" instead of "rename" helped me greatly. I also found the edit() function of QAbstractItemClass to get the second part of my question working.

Similar Threads

  1. Replies: 8
    Last Post: 6th May 2010, 11:17
  2. How to align list items to the center?
    By zgulser in forum Qt Tools
    Replies: 4
    Last Post: 9th February 2009, 09:52
  3. multiple selection of list view items
    By samirg in forum Qt Programming
    Replies: 2
    Last Post: 30th October 2007, 19:05
  4. Comparing Items In List Box
    By kenny_isles in forum Qt Programming
    Replies: 9
    Last Post: 21st February 2007, 13:06
  5. delete items from list box
    By vvbkumar in forum Qt Programming
    Replies: 4
    Last Post: 23rd June 2006, 19:08

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.