Results 1 to 2 of 2

Thread: QUndoStack problem

  1. #1
    Join Date
    Oct 2007
    Location
    Poland
    Posts
    17
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QUndoStack problem

    I have a QTreeWidget with rows:

    A
    B
    C
    D

    and commands:
    1:
    Qt Code:
    1. QUndoStack *stack = new QUndoStack();
    2. stack->push( new InsertCommand( new QTreeWidgetItem(), 0 ) );
    3. stack->undo(); // insertTopLevelItem( 0, newitem );
    To copy to clipboard, switch view to plain text mode 
    Result:

    NewItem
    A
    B
    C
    D

    2:
    Qt Code:
    1. InsertCommand *cmd = new InsertCommand( new QTreeWidgetItem(), 0 );
    2. cmd->undo(); //insertTopLevelItem( 0, newitem );
    To copy to clipboard, switch view to plain text mode 
    Result:

    NewItem
    B
    C
    D

    Why I have two different results. What's the difference between 1 and 2?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QUndoStack problem

    Does the InsertCommand's constructor do anything with the tree widget?

    Qt invokes redo() to perform the command when you push it onto the stack, but it seems that in the first case the command was performed twice.

Similar Threads

  1. Graphics view display problem.
    By kiranraj in forum Qt Programming
    Replies: 3
    Last Post: 20th July 2007, 07:08
  2. [QMYSQL] connection problem
    By chaos_theory in forum Installation and Deployment
    Replies: 5
    Last Post: 2nd July 2007, 09:52
  3. Problem with bitBlt
    By yellowmat in forum Newbie
    Replies: 1
    Last Post: 5th April 2006, 14:08
  4. fftw problem
    By lordy in forum General Programming
    Replies: 1
    Last Post: 16th March 2006, 21:36
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

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.