Results 1 to 4 of 4

Thread: undo for multiple selected items

  1. #1

    Default undo for multiple selected items

    Hello,

    What is the best way to implement a undo stack for multiple items?

    I looked at the undo example, but it only deals with one object.

    If I select two objects and move it, What is the best way to group move/unmove those items? Or do I need to move them individually?

  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 for multiple selected items

    You can begin a macro and then insert undo commands for each item in a group and then end the macro. In such case all the commands will be treated as a single entity and undone or redone at once. Alternatively you can insert an empty undo command on the stack and then insert subsequent commands for each item in the selection passing the earlier inserted empty command as the parent. The effect will be exactly the same.

  3. #3

    Default Re: undo for multiple selected items

    Thanks for the reply wysota,

    I will have to give this a try. Now is there a good way to emit the "objects changed" signal from my Scene or QGraphicsItems? How can I capture a item move event of the QGraphicsScene on multiple selected objects?

  4. #4
    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 for multiple selected items

    Your command's undo and redo methods will be moving objects around. Each move will cause itemChanged to be executed for a respective item, just like if you moved them manually.

Similar Threads

  1. qlistwidget count of selected items
    By tpf80 in forum Newbie
    Replies: 4
    Last Post: 10th December 2009, 13:31
  2. QAbstractItemView and updating selected items
    By Isaac in forum Qt Programming
    Replies: 3
    Last Post: 13th June 2008, 12:23
  3. Getting indexes of selected items
    By gyre in forum Newbie
    Replies: 2
    Last Post: 20th November 2007, 19:23
  4. Move multi selected graphics items
    By tebessum in forum Qt Programming
    Replies: 1
    Last Post: 9th August 2007, 20:00
  5. Replies: 1
    Last Post: 15th March 2007, 20:45

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.