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 448931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T21:43:08+00:00 2026-05-12T21:43:08+00:00

I’m having big troubles with drag & drop. I’ve created a new Qt Designer

  • 0

I’m having big troubles with drag & drop. I’ve created a new Qt Designer Form Class in which I have one QListWidget and one QWidget. Now I want to enable dragging & dropping between these two widgets.

The problem is, where can I add dragEnterEven(…), dragMoveEvent(…) etc. functions? I only have these class.h, class.cpp and class.ui files.

Any help is much appreciated!

-Samuli

  • 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-12T21:43:08+00:00Added an answer on May 12, 2026 at 9:43 pm

    First off, if you haven’t read Qt’s Drag and Drop documentation you really want to start there. What I’m going to tell you is a summary of what’s there. You also should definitely look at the drag and drop examples once you’ve read the description of the process.

    Secondly, and I apologize if I’m misreading this, your question makes it sound like you aren’t quite familiar with C++. You want to declare methods in the .h file, and define them in the .cpp file. You can use the Designer to do some of that declaration of events, but you will need to define the implementation of those events in the .cpp. If that’s not clear you will need to go read more about basic C++ first.

    If you’re ok with those basics, here’s a short summary of how drag and drop works:

    • Dragging is done by:
      • Creating a QDrag. You want to do this in the event that triggers the drag, which is, in all cases I can think of a mouse-click (mousePressEvent or mouseMoveEvent — which one depends on the exact behavior you want to see).
      • Encoding the data you want to be dragged. You do this using MIME-encoding, a standard way of marking what type of document is being dragged. (Examples include text, images, and most other media formats). Assume text for the simple case.
        • Create a QMimeData
        • Set data for the appropriate type (e.g. for text use QMimeData::setText)\
        • Add the mime data to the drag object with QDrag::setMimeData.
        • Call QDrag::exec on your drag object.
    • Dropping is done by:
      • Enabling the acceptDrops property on the given widget using QWidget::setAcceptDrops(true).
      • Define dropEvent on your widget to handle the drop. The data you set in the drag using setMimeData is available as a method of the drop event QDropEvent::mimeData. You need to extract the data out of it using the appropriate document type (e.g. text()).

    Obviously this isn’t complete, but drag and drop has enough steps that you really should read about them in detail once and look at some examples. This summary is meant to give you an idea of what you need to do.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a text area in my form which accepts all possible characters from
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the

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.