Results 1 to 3 of 3

Thread: QGraphicsItem::ItemIsMovable in QGraphicsScene, add actions on drop

  1. #1
    Join Date
    Aug 2015
    Posts
    4
    Thanks
    1
    Qt products
    Qt5
    Platforms
    MacOS X

    Default QGraphicsItem::ItemIsMovable in QGraphicsScene, add actions on drop

    Hi!
    I have a QGraphicsScene set in a QGraphicsView
    In the scene I put a pixmap which is movable.
    If the user drags and drops the pixmap inside the QGraphicsScene, on the drop action, I want to do some things in my program.

    Qt Code:
    1. _scene = std::make_shared<QGraphicsScene>();
    2. ui->graphicsView->setScene(_scene.get());
    3. QGraphicsPixmapItem* pixmap = _scene->addPixmap(QPixmap::fromImage(some_QImage);
    4. pixmap->setFlag(QGraphicsItem::ItemIsMovable);
    To copy to clipboard, switch view to plain text mode 

    Does anyone know how to do such a thing? Is it possible with reimplementation of dragEnterEvent, dragMoveEvent, dropEvent? I tried it in the GraphicsScene and the GraphicsView but it didn't reach my reimplemented event methods.

    Thank you
    Gal

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,328
    Thanks
    36
    Thanked 1,527 Times in 1,478 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsItem::ItemIsMovable in QGraphicsScene, add actions on drop

    If you move the pixmap item, then there is no drag&drop involved at all.

    Cheers,
    _

  3. The following user says thank you to anda_skoa for this useful post:

    gal (6th August 2015)

  4. #3
    Join Date
    Aug 2015
    Posts
    4
    Thanks
    1
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: QGraphicsItem::ItemIsMovable in QGraphicsScene, add actions on drop

    Thanks, I got confused, I needed to use mouseReleaseEvent

Similar Threads

  1. Replies: 0
    Last Post: 25th November 2014, 17:00
  2. QGraphicsItem.ItemIsMovable problem
    By xarchx in forum Qt Programming
    Replies: 0
    Last Post: 31st August 2012, 12:57
  3. Attaching Actions to Items in a QGraphicsScene
    By Goug in forum Qt Programming
    Replies: 1
    Last Post: 13th October 2011, 09:26
  4. Drop Actions
    By MTK358 in forum Newbie
    Replies: 3
    Last Post: 9th September 2010, 21:12
  5. QGraphicsItem::itemIsMovable
    By steg90 in forum Qt Programming
    Replies: 2
    Last Post: 2nd October 2007, 11:53

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.