thejester
6th December 2009, 20:37
Hi,
I would like to implement behaviour like in latest versions of firefox, where a user can drag a tab to the desktop and a new application is started.
I've almost figured out all i need to make it happen except for the "stop sign" that appears under the cursor when dragging stuff to the desktop...
In the code, i have the following mousemove event where the drag is implemented:
void CMyTabBar::mouseMoveEvent(QMouseEvent *event)
{
if (!(event->buttons() & Qt::LeftButton))
{
// Wrong buttn, no drag
return;
}
if ((event->pos() - dragStartPosition).manhattanLength() < QApplication::startDragDistance())
{
// Distance too small, no drag yet !
return;
}
if (event->buttons() & Qt::LeftButton )
{
QDrag *drag = new QDrag(this);
QMimeData *mimeData = new QMimeData;
QPixmap* pixmap = new QPixmap(100,100);
pixmap->grabWidget( this );
drag->setMimeData(mimeData);
drag->setPixmap( *pixmap );
Qt::DropAction dropAction = drag->exec(Qt::MoveAction);
QWidget* t = drag->target () ;
if( t )
{
// there is a target....
}
else
{
// no target...
QWidget* tmp = new SomeWidget();
tmp->show();
}
delete drag;
delete pixmap;
}
}
Any ideas on how to override or remove the stop-sign below the cursor ?
Thanks !
I would like to implement behaviour like in latest versions of firefox, where a user can drag a tab to the desktop and a new application is started.
I've almost figured out all i need to make it happen except for the "stop sign" that appears under the cursor when dragging stuff to the desktop...
In the code, i have the following mousemove event where the drag is implemented:
void CMyTabBar::mouseMoveEvent(QMouseEvent *event)
{
if (!(event->buttons() & Qt::LeftButton))
{
// Wrong buttn, no drag
return;
}
if ((event->pos() - dragStartPosition).manhattanLength() < QApplication::startDragDistance())
{
// Distance too small, no drag yet !
return;
}
if (event->buttons() & Qt::LeftButton )
{
QDrag *drag = new QDrag(this);
QMimeData *mimeData = new QMimeData;
QPixmap* pixmap = new QPixmap(100,100);
pixmap->grabWidget( this );
drag->setMimeData(mimeData);
drag->setPixmap( *pixmap );
Qt::DropAction dropAction = drag->exec(Qt::MoveAction);
QWidget* t = drag->target () ;
if( t )
{
// there is a target....
}
else
{
// no target...
QWidget* tmp = new SomeWidget();
tmp->show();
}
delete drag;
delete pixmap;
}
}
Any ideas on how to override or remove the stop-sign below the cursor ?
Thanks !