在 Qt 中捕捉拖拽退出? [英] Catching a drag exit in Qt?

查看:64
本文介绍了在 Qt 中捕捉拖拽退出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个源自 QWidget 的自定义小部件,我希望能够将其拖放到上面,当拖动鼠标悬停在小部件上时,我想突出显示它以向用户提供一些视觉反馈.在我看来,最简单的方法是在调用 dragEnterEvent 时突出显示,并在拖动退出小部件时取消突出显示,但是我怎样才能捕捉到拖动退出?似乎没有 dragExitEvent 事件处理程序.

I've got a custom widget descended from QWidget that I want to be able to drop onto, and while the drag is hovering over the widget I'd like to highlight it to provide a little visual feedback to the user. Seems to me the simplest way to do this would be to highlight when dragEnterEvent is called and unhighlight when the drag exits the widget, but how can I catch the drag exit? There doesn't seem to be a dragExitEvent event handler.

推荐答案

在索引"选项卡上打开助手",键入drag*event",您将找到 dragLeaveEvent.:)

Open Assistant on the Index tab, type "drag*event" and you will find dragLeaveEvent. :)

这篇关于在 Qt 中捕捉拖拽退出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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