PDA

View Full Version : I want to edit listview's item using contextmenu. How to?



melody:p
3rd August 2012, 10:53
I can edit listview's item when I doubleclicked item.
I using code


setEditTriggers(QAbstractItemView::DoubleClicked | QAbstractItemView::SelectedClicked);


AND I want to editing item by contextmenu.

I want to :
when I select rename action,
item's state change editable, like this:
8090 -> 8089

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

PLEASE HELP ME!

StrikeByte
3rd August 2012, 11:42
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

sonulohani
3rd August 2012, 12:05
Then after that

use


bool QFile::rename ( const QString & newName )


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.