PDA

View Full Version : Cancel last user ever



1111
28th November 2008, 15:20
Hello all,

How to cancel last event?

I have a tree, some of the branches can be renamed, but some names are forbidden. So I catch itemRenamed signal from the tree and check item name. But how I can undone last user operation (rename) if if value is invalid? itemRenamed() function already has modified item name.

Is there any signal than can be caught before applying new item name?

I'm using Qt4.4 and tree is a Q3ListView object instance.

caduel
28th November 2008, 16:24
you have two possibilities here:
1) prevent renaming:
Qt4: QListWidgetItem::setFlags()
Q3ListViewItem::setRenameEnabled()

2) allow the user to do something, and then say "no you don't" afterwards...
I don't like that approach :)
Then, you could integrate the model with QUndoStack (interesting to do, but overkill for you).

HTH

1111
28th November 2008, 17:26
1) prevent renaming:
Qt4: QListWidgetItem::setFlags()
Q3ListViewItem::setRenameEnabled()

But user should be able to rename tree branches.



2) allow the user to do something, and then say "no you don't" afterwards...
I don't like that approach :)

itemRenamed() signal passes renamed item, so I can only say "that was wrong, please turn it back".:D

Any way, is it possible to attach a validator to rename field? I assume, rename field is QLineEdit object.



Then, you could integrate the model with QUndoStack (interesting to do, but overkill for you).

:eek: