Qt-interest Archive, June 2007
Undo/Redo ?
Message 1 in thread
Hi all,
How does Undo-Redo work in QT ?
I understand that QT provides classes to be able to do so such as
QUndoCommand and QUndoStack.
But from the documentation it seems one has to manually push the
commands onto the undo stack everytime a command is invoked.
Or the QApplication object takes care of it and one has to simply create
undo/redo QActions and invoke them ?
Since the QUndoCommand and QUndoStack were introduced only in 4.2
release, is there any example
which shows how to use the classes inan application ?
Thnx
Prateek
Message 2 in thread
Let me rephrase my question to make it more clear.
Is there any default implementation for undo/redo in any of the Qt
widgets/views/frames that takes care of simple commands ?
Thnx
Prateek
________________________________
From: Prateek Tiwari [mailto:ptiwari]
Sent: Wednesday, June 13, 2007 2:20 PM
To: qt-interest@xxxxxxxxxxxxx
Subject: Undo/Redo ?
Hi all,
How does Undo-Redo work in QT ?
I understand that QT provides classes to be able to do so such
as QUndoCommand and QUndoStack.
But from the documentation it seems one has to manually push the
commands onto the undo stack everytime a command is invoked.
Or the QApplication object takes care of it and one has to
simply create undo/redo QActions and invoke them ?
Since the QUndoCommand and QUndoStack were introduced only in
4.2 release, is there any example
which shows how to use the classes inan application ?
Thnx
Prateek
Message 3 in thread
Qt text widgets have standard Ctrl-Z/Shift-Ctrl-Z undo/redo -- try out
one of the examples.
Sam Dutton
SAM DUTTON
SENIOR SITE DEVELOPER
200 GRAY'S INN ROAD
LONDON
WC1X 8XZ
UNITED KINGDOM
T +44 (0)20 7430 4496
F
E SAM.DUTTON@xxxxxxxxx
WWW.ITN.CO.UK
________________________________
From: Prateek Tiwari [mailto:ptiwari@xxxxxxxxxxx]
Sent: Wednesday 13 June 2007 10:30
To: Prateek Tiwari; qt-interest@xxxxxxxxxxxxx
Subject: RE: Undo/Redo ?
Let me rephrase my question to make it more clear.
Is there any default implementation for undo/redo in any of the Qt
widgets/views/frames that takes care of simple commands ?
Thnx
Prateek
________________________________
From: Prateek Tiwari [mailto:ptiwari]
Sent: Wednesday, June 13, 2007 2:20 PM
To: qt-interest@xxxxxxxxxxxxx
Subject: Undo/Redo ?
Hi all,
How does Undo-Redo work in QT ?
I understand that QT provides classes to be able to do so such
as QUndoCommand and QUndoStack.
But from the documentation it seems one has to manually push the
commands onto the undo stack everytime a command is invoked.
Or the QApplication object takes care of it and one has to
simply create undo/redo QActions and invoke them ?
Since the QUndoCommand and QUndoStack were introduced only in
4.2 release, is there any example
which shows how to use the classes inan application ?
Thnx
Prateek
Please Note:
Any views or opinions are solely those of the author and do not necessarily represent
those of Independent Television News Limited unless specifically stated.
This email and any files attached are confidential and intended solely for the use of the individual
or entity to which they are addressed.
If you have received this email in error, please notify postmaster@xxxxxxxxx
Please note that to ensure regulatory compliance and for the protection of our clients and business,
we may monitor and read messages sent to and from our systems.
Thank You.
Message 4 in thread
Hi Prateek,
i think general solution to this problem doesn't exist. I am in the stage of
thinking about the same thing as you, I have studied some code (e.g. qcad,
designer of QT etc), everyone has his own solution. So my idea behind is
following:
the redo/undo stack represents always (for my project) some operation on the
data. It does not automate undo on view/GUI interface. This means, that if
you manage to separate your data and view in the same way like qt4 does its
model/view architecture, you can create class which will watch and store the
differences between your data in given time. Then, after every command
manipulating data (this is easy stuff as you've already managed to divide
between view, data and delegate, so every operation doing something over
data is in your delegate) you call one function of your 'watching' class,
which will compare the actual data structure and the one it stored last
time, and it creates 'data difference' which is stored into the stack.
undo/redo is then just pushing the data from/to stack. The data can be
complex structure of linked lists or whatever else of course.
as i don't have this idea still implemented, this is really just though.
perhaps someone has better idea how to do it ... so I appreciate any
comments on the subject.
Message 5 in thread
If you don't want to use Qt's undo framework, and the text widget
undo/redo isn't enough, you might want to consider rolling back (or
forward!) on the server/database, not the client.
Sam Dutton
SAM DUTTON
SENIOR SITE DEVELOPER
200 GRAY'S INN ROAD
LONDON
WC1X 8XZ
UNITED KINGDOM
T +44 (0)20 7430 4496
F
E SAM.DUTTON@xxxxxxxxx
WWW.ITN.CO.UK
________________________________
From: dejfson [mailto:dejfson@xxxxxxxxx]
Sent: 14 June 2007 21:38
To: qt-interest@xxxxxxxxxxxxx
Subject: Re: Undo/Redo ?
Hi Prateek,
i think general solution to this problem doesn't exist. I am in the
stage of thinking about the same thing as you, I have studied some code
(e.g. qcad, designer of QT etc), everyone has his own solution. So my
idea behind is following:
the redo/undo stack represents always (for my project) some operation on
the data. It does not automate undo on view/GUI interface. This means,
that if you manage to separate your data and view in the same way like
qt4 does its model/view architecture, you can create class which will
watch and store the differences between your data in given time. Then,
after every command manipulating data (this is easy stuff as you've
already managed to divide between view, data and delegate, so every
operation doing something over data is in your delegate) you call one
function of your 'watching' class, which will compare the actual data
structure and the one it stored last time, and it creates 'data
difference' which is stored into the stack. undo/redo is then just
pushing the data from/to stack. The data can be complex structure of
linked lists or whatever else of course.
as i don't have this idea still implemented, this is really just though.
perhaps someone has better idea how to do it ... so I appreciate any
comments on the subject.
Please Note:
Any views or opinions are solely those of the author and do not necessarily represent
those of Independent Television News Limited unless specifically stated.
This email and any files attached are confidential and intended solely for the use of the individual
or entity to which they are addressed.
If you have received this email in error, please notify postmaster@xxxxxxxxx
Please note that to ensure regulatory compliance and for the protection of our clients and business,
we may monitor and read messages sent to and from our systems.
Thank You.