Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1044679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:51:57+00:00 2026-05-16T15:51:57+00:00

In Qt’s undo framework , you can have a stack of QUndoCommand instances. Each

  • 0

In Qt’s undo framework, you can have a stack of QUndoCommand instances. Each of these describes an action in the user interface. In our application, we have a set of views working on a set of models, some in combination, and we often have more than one view working on the same set of models. I’m now looking at the ability to undo actions based on this framework.

Now, I am familiar with the general pattern of having command classes to describe UI actions, but are these supposed to represent a state change in UI elements, or a data change in the underlying model(s)? How much data and state is a command class supposed to contain?

An example to illustrate my point: suppose you have a QStandardItemModel as base model, and a number of proxy models sitting on top of this. Each proxy model will do a transformation of sorts, such as filtering by occurrence of a certain value. Then if I create a command class to specifically alter one value in one of these proxy models, and the filter conditions change, the state of that command class becomes invalid. So I have to include the state of the filter as well, or a mapping to the ultimate, underlying model. Another option is to add commands for all of the state changes in the UI (the ones causing the filter condition to change, for example) as well, but the downside of this appears to be that the list of commands to undo becomes rather large.

What are the best practices here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T15:51:58+00:00Added an answer on May 16, 2026 at 3:51 pm

    It depends somewhat on your application and how it is used, but here are the general guidelines I’ve used in the past for undo commands:

    • Is it part of the data? If so, the user should be able to undo it.
    • Is is saved somehow (remembered between application sessions)? If so, the user should probably be able to undo it.
    • Is it related to the main purpose of the program? If so, undoable.
    • Is it an often-done portion of the workflow? If so, likely undoable.
    • Is it triggered based on something else changing? If so, it should undo when the other item changes back, not by itself.
    • Does it reset every time *X* happens? You might be able to get away with it not being in the undo stack.
    • Is it easily undone via the same motion (hiding/showing extra information, for example)? You probably don’t want it in the undo stack.

    Based on this and what you’ve written, I would probably tie the undo information to both the model (data) and the view, if the filtering is something that happens often and/or can’t easily be changed back. If the filtering is simple (basic substring filtering like searching your email subject lines), then it probably doesn’t need to be part of the undo state, and then undo commands would just be tied to the data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.