如何实现拖放小部件到另一个容器在qt? [英] How to implement drag-n-dropping widget to another container in qt?

查看:125
本文介绍了如何实现拖放小部件到另一个容器在qt?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个有几个容器的窗口。

I have a window with several containers. What is the simplest way to implement drag-n-drop between them?

推荐答案

你必须使用 QDrag * 对象。
然后重新实现:

You have to use a QDrag* object. Then reimplement:

virtual void mousePressEvent(QMouseEvent * event);
virtual void mouseReleaseEvent(QMouseEvent * event);
virtual void mouseMoveEvent(QMouseEvent *event);

在这些事件中,你将管理一个起点(拖拽开始的地方)和一个终点你放下小部件)。您还将使用MIME协议来允许框架管理拖放操作。

Inside those event you will manage a starting point (where the drag starts) and an end point (where you drop the widget). You will also use the MIME protocol to permit the framework to manage the drag n drop operation.

有关拖放的更有用的文章是:拖放

A more useful article on Drag and drop is this: Drag 'n drop

这篇关于如何实现拖放小部件到另一个容器在qt?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆