You were right! It's so non-intuitive, I never would have figured it out on my own. Thanks a million for your help!
For anyone else who might have this problem, here's what I added to my code to get it to accept Drop events. Why I have to accept Move events to get a Drop event, I shall never know, but here it is! :-)
{
event->accept();
}
void MyGraphicsView::dragMoveEvent(QDragMoveEvent *event)
{
event->accept();
}
To copy to clipboard, switch view to plain text mode
// And then to extract the filename(s) for the dragged icon(s)
// Taken from "dropsite" example.
{
const QMimeData *mimeData
= event
->mimeData
();
if (mimeData->hasUrls()) {
QList<QUrl> urlList = mimeData->urls();
for (int i = 0; i < urlList.size() && i < 32; ++i) {
QString url
= urlList.
at(i
).
path();
}
}
// And then to extract the filename(s) for the dragged icon(s)
// Taken from "dropsite" example.
void MyGraphicsView::dropEvent(QDropEvent *event)
{
const QMimeData *mimeData = event->mimeData();
if (mimeData->hasUrls()) {
QList<QUrl> urlList = mimeData->urls();
QString filenames;
for (int i = 0; i < urlList.size() && i < 32; ++i) {
QString url = urlList.at(i).path();
filenames += url + QString("\n");
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks