Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6660027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:06:14+00:00 2026-05-26T02:06:14+00:00

How can I develop drag and drop functionality in QML? I want to drag

  • 0

How can I develop drag and drop functionality in QML? I want to drag and drop one image to another.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T02:06:15+00:00Added an answer on May 26, 2026 at 2:06 am

    At this point in time, you will probably need to use C++, especially if you want to accept drops from outside the QML application (e.g. the user drags a file from a file manager to your app). Here’s an example component class to implement a DropArea item:

    DropArea.h:

    #ifndef DropArea_H
    #define DropArea_H
    
    #include <QDeclarativeItem>
    
    /**
        An oversimplified prototype Item which accepts any drop that includes
        data with mime type of text/plain, and just emits the text.
    */
    class DropArea : public QDeclarativeItem
    {
        Q_OBJECT
        Q_PROPERTY(bool acceptingDrops READ isAcceptingDrops WRITE setAcceptingDrops NOTIFY acceptingDropsChanged)
    
    public:
        DropArea(QDeclarativeItem *parent=0);
        bool isAcceptingDrops() const { return m_accepting; }
        void setAcceptingDrops(bool accepting);
    
    signals:
        void textDrop(QString text);
        void acceptingDropsChanged();
    
    protected:
        void dragEnterEvent(QGraphicsSceneDragDropEvent *event);
        void dragLeaveEvent(QGraphicsSceneDragDropEvent *event);
        void dropEvent(QGraphicsSceneDragDropEvent *event);
    
    private:
        bool m_accepting;
    };
    
    #endif
    

    DropArea.cpp:

    #include <QGraphicsSceneDragDropEvent>
    #include <QMimeData>
    #include "DropArea.h"
    
    DropArea::DropArea(QDeclarativeItem *parent)
            : QDeclarativeItem(parent),
        m_accepting(true)
    {
        setAcceptDrops(m_accepting);
    }
    
    void DropArea::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
    {
        event->acceptProposedAction();
        setCursor(Qt::DragMoveCursor);
    }
    
    void DropArea::dragLeaveEvent(QGraphicsSceneDragDropEvent *event)
    {
        unsetCursor();
    }
    
    void DropArea::dropEvent(QGraphicsSceneDragDropEvent *event)
    {
        emit textDrop(event->mimeData()->text());
        unsetCursor();
    }
    
    void DropArea::setAcceptingDrops(bool accepting)
    {
        if (accepting == m_accepting)
                    return;
    
        m_accepting = accepting;
        setAcceptDrops(m_accepting);
        emit acceptingDropsChanged();
    }
    

    your QML:

    DropArea {
        onTextDrop: ...
    }
    

    And you can implement a DragSourceArea similarly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to develop a drag/drop functionality that works on both desktop and
I want to learn C++ so that i can develop C++ Python modules for
I have been asked to build an application where I can drag and drop
I want to know how I can develop GUI applications(32 Bits) without using Delphi
=I am trying to develop a simple drag/drop UI in my web application. An
I want to know if I can develop graphics application with DirectX using C#?
I want to know if i can develop an app that would download books
Android view is in xml file, and we can drag n drop controls to
Is anyway to develop black berry apps with drag and drop IDE (interface builder)
I'm trying to develop a system where users can drag icons (which represent user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.