Results 1 to 3 of 3

Thread: Undo/Redo Functionality

  1. #1
    Join Date
    Aug 2014
    Posts
    4
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Undo/Redo Functionality

    I have a Qt Graphics Application that can draw QGraphicsItems like line, circle, ellipse, etc.

    My entities are implemented using QGraphicsItemGroup. The particular groups are being added to the QList<QGraphicsItemGroup *>.

    Now I want to implement undo/redo functionality to it. I have read that I can use Undo Framework(QUndoCommand, QUndoStack, etc.) for that but then I'd have to make use of command objects, which restricts my implementation to commands only.

    Is there any other approach something like returning to previous state of the graphicsScene? Do I have to make custom functionality for undo/redo?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Undo/Redo Functionality

    No, there is no alternative which is built into graphics view. In theory you could be cloning all items in the scene but that's probably more work than implementing commands for all your operations.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Undo/Redo Functionality

    Quote Originally Posted by Gurjot View Post
    Now I want to implement undo/redo functionality to it. I have read that I can use Undo Framework(QUndoCommand, QUndoStack, etc.) for that but then I'd have to make use of command objects, which restricts my implementation to commands only.
    What do you mean with "restricts my implementation to commands only"?

    A command in the context of undo/redo is just an interface for a state change that can be applied and reverted.

    What kind of operation that does not change the state of the application would you want to undo?

    Cheers,
    _

Similar Threads

  1. Replies: 0
    Last Post: 21st January 2014, 07:05
  2. qt undo/redo
    By giugio in forum Qt Programming
    Replies: 1
    Last Post: 12th November 2012, 17:31
  3. undo/redo example has refactored
    By n_vova in forum Qt Programming
    Replies: 1
    Last Post: 10th May 2012, 11:04
  4. QTextEdit undo/redo
    By Derf in forum Qt Programming
    Replies: 1
    Last Post: 6th August 2009, 10:12
  5. Implement Undo Redo
    By ankurjain in forum Qt Programming
    Replies: 5
    Last Post: 28th March 2006, 14:17

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.