Results 1 to 3 of 3

Thread: Copy - Paste QGraphicsItem on QGraphicsScene

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Feb 2010
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Copy - Paste QGraphicsItem on QGraphicsScene

    Ok guys, I managed to figure out how this could be done.

    Implemented the keyPressEvent and handled as below
    Qt Code:
    1. if (pKeyEvent->key() == Qt::Key_C && pKeyEvent->modifiers() & Qt::ControlModifier)
    2. {
    3. listCopiedItems = this->selectedItems();
    4. }
    5.  
    6.  
    7. if (pKeyEvent->key() == Qt::Key_V && pKeyEvent->modifiers() & Qt::ControlModifier)
    8. {
    9. for(int i=0; i< listCopiedItems.count(); i++)
    10. {
    11. //the same implementation I did to construct the original item during creation after taking the co-ordinates from the original and did a setPos of the item to paste it with a small offset from the original item
    12. }
    13. }
    To copy to clipboard, switch view to plain text mode 
    Thanks everyone who tried to think about this.

    cheers!
    Last edited by pran; 16th February 2012 at 04:59.

Similar Threads

  1. QGraphicsView Copy and Paste
    By stevel in forum Qt Programming
    Replies: 14
    Last Post: 13th January 2014, 07:57
  2. copy and paste
    By hubipet in forum Qt Tools
    Replies: 1
    Last Post: 17th July 2009, 06:19
  3. Copy-Paste files
    By Lele in forum Qt Programming
    Replies: 11
    Last Post: 4th April 2008, 14:15
  4. using cut(), copy(), paste()
    By systemz89 in forum Newbie
    Replies: 5
    Last Post: 18th December 2007, 14:47
  5. Copy/Paste in TableView
    By bronte in forum Qt Programming
    Replies: 2
    Last Post: 10th September 2006, 21:36

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
  •  
Qt is a trademark of The Qt Company.