hi, I need to implement drag and drop between to QLabel. I need if this is possible...thanks
Qt Code:
{ setAcceptDrops(TRUE); }To copy to clipboard, switch view to plain text mode
hi, I need to implement drag and drop between to QLabel. I need if this is possible...thanks
Qt Code:
{ setAcceptDrops(TRUE); }To copy to clipboard, switch view to plain text mode
Regards
This is only the 1st step in many to implement drag and drop....
Check out the DND examples in QTDIR, but to give you a head up you will need to do the following...
Drag Side:
Implement mousePressEvent
Record an inital point
Implement mousePressEvent
Clear the inital point
Implement mouseMoveEvent
Compare initlaPoint to current pount. If its a reasonable distance..
Create a QDrag
Create a QMimeData (Could be text, pixmap, image, URL, HTML. Subclass for more)
Set the data on the drag
call drag->start(..)
Drop Side
In constructor
setAcceptDrops(TRUE);
Implement dragEnterEvent or dragMoveEvent
Ask the event for the mimeData and inspect the supported types
Decide if you can support the types.
Implement dragEnterEvent or dragMoveEvent
Ask the event for the mimeData
Use the data however you want.
Once you get further in this project, feel free to ask more questions.
--Justin Noel
justin@ics.com
Oops, clear the initial point in mouseReleaseEvent....
If you use two QLineEdits, you will get the drag and drop for free. You can change their colors to look like labels if necessary.Originally Posted by mickey
Save yourself some pain. Learn C++ before learning Qt.
Unless said QLabel is displaying a QPixmap or QMovie....
--Justin
there are pretty good examples for drag and drop in the docs
http://doc.trolltech.com/3.3/dnd.html
qt/examples/dragdrop
perfection is an illusion which is stopping me from starting now and finishing on time
Bookmarks