Qt 托盘图标拖放
有谁知道是否可以使用 Qt 对托盘图标进行拖放操作?
Does anyone know if it is possible to use drag and drop with a tray icon using Qt?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
有谁知道是否可以使用 Qt 对托盘图标进行拖放操作?
Does anyone know if it is possible to use drag and drop with a tray icon using Qt?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(2)
我一直在做一些研究,这就是我得出的结论:
QSystemTrayIcon 无法显式处理拖/放事件。不过,有一个基于 Spifftastic 托盘图标定位方法的解决方法。
并将其放置为简短的图标
并截取它的屏幕截图。
图标的顺序,您可以
通过屏幕截图进行搜索并
找到特定的图标
地点。
位于图标上方并用作
放下目标。
我还没有研究操作的一些细节,但这就是它的要点。总的来说,这是一种很奇怪的方式,但考虑到没有其他方法可以做到这一点,我认为这是可以接受的。
Fluffy App(用 C# 编写)使用 Spifftastic 方法来定位托盘图标。我假设有关透明窗口的部分是他们如何实现这一点的,但我还没有反编译和检查他们的系统。
I've been doing some research and here is what I have come up with:
A QSystemTrayIcon cannot explicitly handle a drag/drop event. However there is a workaround based on the Spifftastic tray icon location method.
and place it as the icon for a brief
moment and take a screenshot of it.
sequence for the icon, you can
search through the screenshot and
locate the particular icon's
location.
over the icon and is used as the
drop target.
I have yet to work at a few of the finer details of the operation but that is the gist of it. All things considered it is a hacky way of things but given that there are no other ways to do this I think it is acceptable.
Fluffy App (written in C#) uses the Spifftastic method to locate the tray icon. I'm assuming the part about the transparent window is how they accomplish that but I have yet to decompile and examine their system.
由于 QSystemTrayIcon 是 QObject,而不是 QWidget,我的猜测是这是不可能的。系统托盘图标并不真正属于 Qt——它被传递到“桌面”,即 Gnome/KDE/Windows/Mac 的任何部分正在绘制相关区域。至少在 Mac 上,您将把鼠标放在菜单栏上,这将是一个非常奇怪的 UI。对于 Gnome 和 KDE,它是 FreeDesktop.org 标准,但我再次认为您的进程实际上并不进行绘图,因此 Qt 无法向您获取诸如拖放之类的事件。
Since QSystemTrayIcon is a QObject, not a QWidget, my guess is this is not possible. The system tray icon isn't really owned by Qt - it's passed on to the 'desktop', i.e whatever part of the Gnome/KDE/Windows/Mac is drawing the relevant area. At least on Mac, you'd be dropping on the menu-bar, which would be a very strange UI. For Gnome and KDE it's a FreeDesktop.org standard, but again I don't think its your process which actually does the drawing, and hence there's no way for Qt to get events such as drag and drop to you.