Qt-interest Archive, January 2007
Image Drag/Drop on Windows
Message 1 in thread
I have ported a Qt app. I wrote for linux to my XP machine. All works
find except Image dropping into my picture widget. The following code
worked in linux. But, in XP, I don't even get to the body of the "if"
in dragEnterEvent. The picture (.png) is being drug from a standard
Windows Explorer window. ??
Mike
---------------------------------------------------------------------------------------------
void PictureWidget::dragEnterEvent(QDragEnterEvent *event)
{
if (event->mimeData()->hasFormat("text/plain")){
event->acceptProposedAction();
}
}
void PictureWidget::dropEvent(QDropEvent *event)
{
if (event->mimeData()->hasText()) {
QUrl url(event->mimeData()->text());
image.load(url.path());
repaint();
emit picDropped(url.path());
event->acceptProposedAction();
} else {
event->ignore();
}
}
-----------------------------------------------------------------------------------------------
--
[ signature omitted ]
Message 2 in thread
On 30.01.07 19:04:56, Mike Adolf wrote:
> I have ported a Qt app. I wrote for linux to my XP machine. All works find
> except Image dropping into my picture widget. The following code worked in
> linux. But, in XP, I don't even get to the body of the "if" in dragEnterEvent.
> The picture (.png) is being drug from a standard Windows Explorer window. ??
Well, then your mime data doesn't have text/plain content type. My
guess would be that such a drag has image/png type so you need to find a
way to handle image/png, image/jpeg and so on too.
Andreas
--
[ signature omitted ]