Dear visitor, welcome to QtForum.org.
If this is your first visit here, please read the Help. It explains in detail how this page works.
To use all features of this page, you should consider registering.
Please use the registration form, to register here or read more information about the registration process.
If you are already registered, please login here.
Drag and Drop QFrame
Hi,
I am trying to implement drag and drop in a frame consisitin of many frames. I have implemented the mechanism however i would lke to draw out the frame outline(user can easily visual the area of the frame and where to drop) while draggin is in progress. i realised that the Draggable Icon examples uses the following code to draw out the label while moving
|
Source code
|
1
2
3
4
|
QDrag *drag = new QDrag(this);
drag->setMimeData(mimeData);
drag->setPixmap(pixmap);
drag->setHotSpot(event->pos() - child->pos());
|
In QFrame there is no pixmap. Is there a way to work around. Thank for all help .
Cheers
When you start the drag you can send a signal. Connect the signal to some slot that 'draw out the frame outline'. I don't know what you mean by 'draw out the frame outline', though.
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.
Hi Amleto ,
I am trying to create draggable frame . When the frame is drag , i would like to show the rect() of the frame so the user can easily check if there is space for the dragged frame. Should the draw method be linked to the dragMoveMethod ?
hmm, so maybe you need to make a custom pixmap to add to the drag then.
Try this:
use pixmap = QPixmap::grabWidget(frame) on the frame that is being dragged
call drag->setPixmap(pixmap);
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.
Works great , the result is better than drawing an outline . Thanks Amleto .