Seite 1 von 1

Drop-Event nur nach MouseMove?

Verfasst: 9. April 2008 18:17
von junior0007
Hallo,

ich habe ein kleines Problem beim Drag&Drop von einem QListWidget zu einem QWidget. Das Drop-Event wird scheinbar nur ausgelöst, wenn die Maus bewegt wird.

Mit der normalen Maus fällt dieses Phänomen gar nicht so sehr auf, wohl aber bei einem Trackpad...

Hat jemand ne Idee, woran das liegen mag?

Der Code vom ListWidget:

Code: Alles auswählen

void ListWidget::startDrag()
{
	PosListWidgetItem* item = getCurrentPLWItem();
	if (item)
	{
		QMimeData* mimeData = new QMimeData;
		mimeData->setText(QString::number(item->getCId()));
		QDrag* drag = new QDrag(this);
		drag->setMimeData(mimeData);
		drag->setPixmap(item->icon().pixmap(iconSize()));
		if (drag->start(Qt::CopyAction) == Qt::CopyAction)
		{
			//cout << "erfolgreich" << endl;
		}
	}
}
Und im QWidget:

Code: Alles auswählen

void PicWidget::dragEnterEvent(QDragEnterEvent* e)
{
	ShotsListWidget* source=qobject_cast<ListWidget*>(e->source());
	if (source)
	{
		e->setDropAction(Qt::CopyAction);
		e->accept();
	}
}

void PicWidget::dragMoveEvent(QDragMoveEvent* e)
{
	ShotsListWidget* source = qobject_cast<ListWidget*>(e->source());
	if (source)
	{
		e->setDropAction(Qt::CopyAction);
		e->accept();
	}
}

void PicWidget::dropEvent(QDropEvent* e)
{
	ListWidget* source = qobject_cast<ListWidget*>(e->source());

	if (source)
	{
		const QMimeData* mimeData = e->mimeData();
		unsigned int posId = (unsigned int)mimeData->text().toInt();
	}
}