Hi guys.
I have a few questions about drag & drop.
How can I get current drag item in QMimeData?
I have the code:
{
if(event->mimeData()->hasFormat("text/uri-list"))
event->acceptProposedAction();
else if(event->mimeData()->hasFormat("image/*"))
event->acceptProposedAction();
}
//--------------------------------------------------------------
{
//ui->textEdit_2->setText (event->mimeData()->text());
mime
->setImageData
(QImage("/home/programmer/Documents/qet/images/cute.jpg"));
QImage image
= qvariant_cast<QImage>
(mime
->imageData
());
painter.drawImage(rect(),image);
ui->label_3->setPixmap(pix);
event->acceptProposedAction();
}
void qet::dragEnterEvent(QDragEnterEvent *event)
{
if(event->mimeData()->hasFormat("text/uri-list"))
event->acceptProposedAction();
else if(event->mimeData()->hasFormat("image/*"))
event->acceptProposedAction();
}
//--------------------------------------------------------------
void qet::dropEvent(QDropEvent *event)
{
//ui->textEdit_2->setText (event->mimeData()->text());
QMimeData *mime =new QMimeData;
mime->setImageData(QImage("/home/programmer/Documents/qet/images/cute.jpg"));
QPixmap pix(200,200);
QPainter painter(&pix);
QImage image = qvariant_cast<QImage>(mime->imageData());
painter.drawImage(rect(),image);
ui->label_3->setPixmap(pix);
event->acceptProposedAction();
}
To copy to clipboard, switch view to plain text mode
And, when some image is dragged mainwindow, there is always 1 image, I can't get "current dragging image".
where can I save that, in what kind of buffer, and how to do that in my situation
p.s sorry for pure English.
Thanks and best regards from me.
Bookmarks