[Interest] QUndoStack

Jean-Michaël Celerier jeanmichael.celerier at gmail.com
Sun Jun 19 10:33:57 CEST 2016


I had this problem with QUndoStack (sometimes you need a command to be
executed before, after, sometime you need to push a command without it ever
executing) so I made my own command stack :

https://github.com/OSSIA/i-score/blob/master/base/lib/core/command/CommandStack.hpp

Here are also some base classes used for commands throughout the software :
https://github.com/OSSIA/i-score/tree/master/base/lib/iscore/command

Dispatchers allows to update / merge commands at compile time and without
memory allocation instead of runtime when it becomes a performance concern.

Best
Jean-Michaël

On Fri, Jun 17, 2016 at 7:56 PM, Mike Jackson <imikejackson at gmail.com>
wrote:

> Yes, we have already executed what constitutes the command by the time we
> push it onto the stack. Maybe we are not using QUndoStack correctly then?
> we should be creating the command that _should_ get executed, place it on
> the stack, which will then execute the command.
>
> Still seems odd but we can look at doing that.
> --
> Mike Jackson  [mike.jackson at bluequartz.net]
>
>
>
> Elvis Stansvik wrote:
>
>> 2016-06-17 18:18 GMT+02:00 Mike Jackson<imikejackson at gmail.com>:
>>
>>> We are using the QUndoStack and when we "push()" onto the stack the
>>> actual
>>> QUndoCommand is being executed. In the documentation is seems as though I
>>> could set the "id" of the QUndoCommand to -1 and NOT have it executed but
>>> after looking more close at the docs and the actual source code the
>>> QUndoCommand will definitely be executed when pushed onto the stack. This
>>> behavior does not make sense to me and I am probably missing something
>>> simple about how to use the QUndoStack. Could someone offer an
>>> explanation
>>> of why my command gets executed? And also how do I get my undocommand on
>>> the
>>> stack **without** executing the command?
>>>
>>
>> I haven't used QUndoStack much myself, but to me what you describe
>> does not make sense. An undo stack is supposed to represent what has
>> happened (this history), so why should a command not be executed when
>> pushed? Is it that you have already executed it manually?
>>
>> Either way, I think a command will always be executed when pushed, so
>> that's what you need to work with. The -1 id thing seems to be just
>> for controlling the merging behavior.
>>
>> Elvis
>>
>> Thanks
>>>
>>> --
>>> Michael A. Jackson
>>> BlueQuartz Software, LLC
>>> [e]: mike.jackson at bluequartz.net
>>> _______________________________________________
>>> Interest mailing list
>>> Interest at qt-project.org
>>> http://lists.qt-project.org/mailman/listinfo/interest
>>>
>> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160619/4977d385/attachment.html>


More information about the Interest mailing list