[Qt-interest] QDrag::setDragCursor- what does it do?
Malyushytsky, Alex
alex at wai.com
Thu Jun 23 02:12:18 CEST 2011
Have you checked that cursor.pixmap() returns a valid pixmap?
According to my impression it might not.
Alex
From: qt-interest-bounces+alex=wai.com at qt.nokia.com [mailto:qt-interest-bounces+alex=wai.com at qt.nokia.com] On Behalf Of John Weeks
Sent: Wednesday, June 22, 2011 4:11 PM
To: Qt-interest Interest
Subject: [Qt-interest] QDrag::setDragCursor- what does it do?
The description of QDrag::setDragCursor suggests that it might change the mouse pointer while a drag is in progress. But no matter what I do, the cursor remains the arrow cursor. Does this call do something different from what I think it does?
Here's the code I'm using to initiate dragging. It works well, except that I'd really like to hide the pointing arrow while dragging, and just have the pixmap I set using QDrag->setPixmap(). I'm using Qt::OpenHandCursor just for testing, so that if something happens, I'll be able to see it.
void InfoWindowCursorButton::mouseMoveEvent ( QMouseEvent * event )
{
if ((event->pos() - clickPosition).manhattanLength() < QApplication::startDragDistance())
return; // no drag unless movement is greater than the standard drag start distance
event->accept();
QDrag *drag = new QDrag(this);
QMimeData *mimeData = new QMimeData;
QByteArray data(1, 'A'+cursorType);
mimeData->setData("application/x-wavemetrics-cursordata", data);
drag->setMimeData(mimeData);
QString cursorFile;
QString cursorMaskFile;
if (cursorType & 1)
{
cursorFile = ":/Cursors/Cursors/CursorBoxGraph.png";
cursorMaskFile = ":/Cursors/Cursors/CursorBoxGraphMask.png";
}
else
{
cursorFile = ":/Cursors/Cursors/CursorCircleGraph.png";
cursorMaskFile = ":/Cursors/Cursors/CursorCircleGraphMask.png";
}
QPixmap dragpic(cursorFile);
QBitmap dragmask(cursorMaskFile);
dragpic.setMask(dragmask);
drag->setPixmap(dragpic);
QPoint hotspot(8,8);
drag->setHotSpot(hotspot);
QCursor cursor(Qt::OpenHandCursor);
drag->setDragCursor(cursor.pixmap(), Qt::MoveAction);
Qt::DropAction dropAction = drag->exec(Qt::CopyAction | Qt::MoveAction, Qt::MoveAction); // "copy" and "move" have no meaning here
}
Thanks!
John Weeks
---------------------------------------------------------------------------------------------------
Weidlinger Associates, Inc. made the following annotations.
“This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you.”
“Please consider our environment before printing this email.”
More information about the Qt-interest-old
mailing list