Qt World Summit: Register Today!

How to drag an Image to the widget?

  • Here is part of my code, I set "setAcceptDrops(true)" and use "hasImage()" but it still shows like follows.
    Besides, how can I get the filename of the dragged image?

    void ImageWidget::dragEnterEvent(QDragEnterEvent *event)
    	if (event->mimeData()->hasImage())
    void ImageWidget::dropEvent(QDropEvent *event)
    	QString fileName;
    	if (!fileName.isEmpty())
    		save_xmlfile = QFileInfo(fileName).fileName();
    		image_index = save_xmlfile.section(".",0,0);
    		load_status = true;

  • Moderators

    CLOSED (double post)

Log in to reply