[Solved] QListWidgetItem rename
-
I have a QListWidget that the user populates with QListWidgetItems. The user can double-click the list item to rename it. I would like to programmatically put the list item in that 'renaming state', like when you press F2 in Windows Explorer with a file selected. How can I accomplish this?
-
First, make QListWidgetItems editable. You can do it by setting Qt::ItemIsEditable flag. Then connect listWidgets itemClicked signal to your slot that changes item state to edit. ( QListWidget::editItem( QListWidgetItem* ) ) Afaik, for F12, you have to install event filter to listwidget or create custom listwidget.
-
t3chNo is right, this is the main philosophy :)
Joking aside, I guess that everybody's right, the point of view is different.
Mine is: "Ok, assume that the item is editable ... which are the input keys (mouse or keyboard) that are allowed to enter in edit mode??" ... and these should be set.
t3chNo is: "You should tell me if the single item is editable or not".
Of course, if the default flags() allows editing, mine is the straightforward solution. Otherwise, you should do both.
T.