Results 1 to 3 of 3

Thread: I want to edit listview's item using contextmenu. How to?

  1. #1
    Join Date
    Jul 2012
    Posts
    23
    Thanks
    3

    Default I want to edit listview's item using contextmenu. How to?

    I can edit listview's item when I doubleclicked item.
    I using code
    Qt Code:
    1. setEditTriggers(QAbstractItemView::DoubleClicked | QAbstractItemView::SelectedClicked);
    To copy to clipboard, switch view to plain text mode 

    AND I want to editing item by contextmenu.

    I want to :
    when I select rename action,
    item's state change editable, like this:
    www.png -> ddd.png

    How to I want DO?
    It's so hard...

    PLEASE HELP ME!

  2. #2
    Join Date
    May 2012
    Posts
    136
    Thanks
    2
    Thanked 27 Times in 24 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: I want to edit listview's item using contextmenu. How to?

    You will have to create an editor that can do it for you and you have to make a deligate
    Then you have to attach deligate to the view by calling setItemDelegate(your deligate here);

    here you can find some more information here http://www.qtrac.eu/aqpbook.html
    download the source from here http://www.qtrac.eu/aqpbook.zip (this is the source used in the book) and take a look at the Zipcodes1 example

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

    melody:p (6th August 2012)

  4. #3
    Join Date
    May 2012
    Location
    Bangalore, India
    Posts
    271
    Thanks
    29
    Thanked 50 Times in 47 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: I want to edit listview's item using contextmenu. How to?

    Then after that

    use
    Qt Code:
    1. bool QFile::rename ( const QString & newName )
    To copy to clipboard, switch view to plain text mode 

    Renames the file currently specified by fileName() to newName. Returns true if successful; otherwise returns false.

    If a file with the name newName already exists, rename() returns false (i.e., QFile will not overwrite it).

    The file is closed before it is renamed.
    Heavy Metal Rules. For those about to rock, we salute you.
    HIT THANKS IF I HELPED.

  5. The following user says thank you to sonulohani for this useful post:

    melody:p (6th August 2012)

Similar Threads

  1. Item edit in QTableWidget
    By manmohan in forum Newbie
    Replies: 3
    Last Post: 29th April 2011, 16:56
  2. listview item focusing
    By addu in forum Qt Programming
    Replies: 7
    Last Post: 18th August 2009, 07:07
  3. Set default Selected item in ListView (QSqlQueryModel)
    By jeffpogo in forum Qt Programming
    Replies: 0
    Last Post: 26th May 2009, 22:12
  4. getting clicked item from listview
    By addu in forum Qt Programming
    Replies: 6
    Last Post: 14th May 2009, 10:33
  5. Replies: 8
    Last Post: 15th May 2007, 09:21

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.