I want the mouse cursor to be in the position where the mouse was clicked on the widget or in the center of the widget.
For example if the widget is a rectangle and it is in drag event it appears like in the image below, event I've clicked in the center and started to drag:
Where is the red circle is the mouse cursor every time, wherever I "pick-up" the widget.
In the mousePressEvent
, I do something like:
void
myQFrame::mousePressEvent( QMouseEvent* event )
{
if( event->button() == Qt::LeftButton )
{
QDrag* drag = new QDrag( this );
QMimeData* mimeData = new QMimeData;
//....other stuff
drag->setMimeData( mimeData );
QPixmap widgetPixmap(this->size());
this->render( &widgetPixmap, QPoint(), QRegion( this->rect() ) );
}
}
Haw can I set the cursor to be in center for example if the widget was picket from the center?