简单的提供一两个函数供后人使用。。
void qturl1::dragEnterEvent(QDragEnterEvent *event)
{
if(event->mimeData()->hasFormat("text/uri-list"))
event->acceptProposedAction();
}
void qturl1::dropEvent(QDropEvent *event)
{
QList<QUrl> urls = event->mimeData()->urls();
if(urls.isEmpty())
return;
QString fileName= urls.first().toLocalFile();
if(fileName.isEmpty())
{
return;
}
else
{
QPushButton *bttonT=new QPushButton();
QPixmap pixmap = QPixmap(fileName);
QBrush Brush(pixmap);
bttonT->setIcon(QIcon(pixmap.scaled(30, 30)));
bttonT->setIconSize(QSize(50, 50));
myLayoutleft->addWidget(bttonT);
}
}