Hi! I have Widget MainWindow and tableWidget in MainWindow. tableWidget is placed in the center of MainWindow. I need drop audio-files on Main Window. If i drop files to MainWindow then do such function, if i drop files on table - do another function. Can you help me?
i try to realize drop on mainWindow:
in header:
if (pe->mimeData()->hasFormat("text/uri-list")){
pe->acceptProposedAction();
}
}
void dragEnterEvent (QDragEnterEvent *pe){
if (pe->mimeData()->hasFormat("text/uri-list")){
pe->acceptProposedAction();
}
}
void dropEvent (QDropEvent* pe);
To copy to clipboard, switch view to plain text mode
in constructor
setAcceptDrops(true);
setAcceptDrops(true);
To copy to clipboard, switch view to plain text mode
and
QList<QUrl> urlList=pe->mimeData()->urls();
foreach
(QUrl url, urlList
){ str<<url.toString();
}
// Some function with str
}
void MainWindow::dropEvent(QDropEvent *pe){
QList<QUrl> urlList=pe->mimeData()->urls();
QStringList str;
foreach (QUrl url, urlList ){
str<<url.toString();
QMessageBox::information(this,"yeah",url.toString());
}
// Some function with str
}
To copy to clipboard, switch view to plain text mode
But i have crash on drop.
Bookmarks