Results 1 to 2 of 2

Thread: QDrag - Change the image display while dragging

  1. #1
    Join Date
    Oct 2011
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default QDrag - Change the image display while dragging

    I started a drag with image.

    Qt Code:
    1. QDrag* drag = new(QDrag)(this);
    2. drag->setPixmap(*pixmap);
    3. drag->exec(Qt::CopyAction | Qt::MoveAction);
    To copy to clipboard, switch view to plain text mode 

    I want to change the image display when my drag reach certain point in the widget. Is there anyway to retrieve the drag object so that I could change the image?

  2. #2
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDrag - Change the image display while dragging

    The QDrag API explicitely states that the pixmap can only be set before starting the drag operation. However a cursory look at Qt sources (I'm using Qt 4.7 branch from gitorious as a reference) seems to indicate that the pixmap is actually updated on every drag move event so the following *could* work :

    1. make the QDrag object a member of your widget (not strictly necessary, the important point is that it is accessible from your widget's event handlers)
    2. do whatever position check you need in your widget's dragMoveEvent and call setPixmap on the QDrag object as needed
    Current Qt projects : QCodeEdit, RotiDeCode

Similar Threads

  1. How to display .svg image in Qt
    By GT Development in forum Qt Programming
    Replies: 4
    Last Post: 28th September 2011, 06:17
  2. Replies: 1
    Last Post: 24th August 2011, 14:09
  3. Application Resizing on Display resolution change
    By augusbas in forum Qt Programming
    Replies: 1
    Last Post: 26th April 2010, 12:12
  4. Display image
    By Pesho in forum Qt Programming
    Replies: 1
    Last Post: 14th September 2007, 00:21
  5. Can't change the text display of a QTreeview item.
    By johnny_sparx in forum Qt Programming
    Replies: 3
    Last Post: 2nd June 2006, 01:03

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.