Qt tray drag icon

Does anyone know if it is possible to use drag and drop using the tray icon using Qt?

+6
c ++ qt qt4 drag-and-drop
source share
2 answers

I am doing some research, and here is what I came up with:

A QSystemTrayIcon cannot explicitly handle the drag / drop event. However, there is a workaround based on the method of arranging the icons in the Spifftastic tray.

  • You create a uniquely colored icon and place it as an icon for a short one and take a screenshot.
  • Given that you know the color of the sequence for the icon, you can search in the screenshot and find a specific icon for the place.
  • A transparent widget is positioned above the icon and is used as a drop.

I have yet to work on several details of the operation, but this is the essence of this. All things are considered a hacky way of things, but given that there are no other ways to do this, I think this is acceptable.

The Fluffy App (written in C #) uses the Spifftastic method to find the tray icon. I take part in a transparent window, how they do it, but I still have to decompile and study their system.

+6
source share

Since QSystemTrayIcon is a QObject and not a QWidget, I think this is not possible. The icon in the system tray does not actually belong to Qt - it is transferred to the "desktop", i.e. Whatever part of Gnome / KDE / Windows / Mac draws the corresponding area. At least on a Mac you would throw in a menu, which would be a very strange interface. For Gnome and KDE, this is the FreeDesktop.org standard, but again I don’t think it’s your process that actually draws the drawing, and therefore Qt has no way to get events like drag and drop.

+1
source share

All Articles