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

  • SEARCH
  • Home
  • 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 7711633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:25:30+00:00 2026-06-01T01:25:30+00:00

How can I undo or revert an user entry on a QTableView popuplated by

  • 0

How can I undo or revert an user entry on a QTableView popuplated by QStandarItemModel?

I have connected dataChanged signal with a handler where I validate the data…

connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(validateData(QModelIndex,QModelIndex)));

…but in case user entry is wrong I want to revert or undo the user entry to the previous value of the item.

I have read about revert() member inherited from QAbstractItemModel but I can’t understand how it works exactly. Documentation says “Lets the model know that it should discard cached information.” but I’m not sure whether the data the user entered is cached or is already stored on the model.

Anyway if I try…

model->revert();

…after a wrong user entry it does not work.

Thanks in advance!

  • 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-06-01T01:25:32+00:00Added an answer on June 1, 2026 at 1:25 am

    Check out Qt’s undo framework. The introduction at the documentation says:

    Qt’s Undo Framework is an implementation of the Command Pattern,
    for implementing undo/redo functionality in applications.

    The Command pattern is based on the idea that all editing in an
    application is done by creating instances of command objects. Command
    objects apply changes to the document and are stored on a command
    stack. Furthermore, each command knows how to undo its changes to
    bring the document back to its previous state. As long as the
    application only uses command objects to change the state of the
    document, it is possible to undo a sequence of commands by traversing
    the stack downwards and calling undo on each command in turn. It is
    also possible to redo a sequence of commands by traversing the stack
    upwards and calling redo on each command.

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

Sidebar

Related Questions

I want to create previous versions so a user can undo changes made and
I run at path/test rm -r * The tutorial says that I can undo
This maybe a stupid question, but as I can not easily undo my change
Can anyone give an idea of how should I implement undo/redo of cutting/copying/pasting of
I was just wondering how I can get a single tap to undo the
instead of popup from center can we change to another animation (eg, undo animation)?
How can I undo the most recently executed mysql query?
How can I undo the creation of a branch in Mercurial? For example, if
I have pulled git repository form github in my user folder and all files
I have a single row of data in a SQL Server table that I'm

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.