Answer the question
In order to leave comments, you need to log in
QSystemTrayIcon drag-and-drop how?
I would like to process the drag-n-grop file on the system tray icon in a Qt application.
Google gave:
Here they say it is not necessary and impossible, however, when they link to droplr, they calm down and retreat.
Here it is more interesting. It is advised to make a transparent widget on top of the tray icon. However, I'm not sure how it will behave when changing the focus and changing the position of the tray, so beware of such a crutch.
Maybe somehow you can play with inheritance, or who has an implementation already? The main requirement would be to support at least two operating systems: Linux (GNOME, KDE) and MacOS. Well, Windows will not be superfluous.
Answer the question
In order to leave comments, you need to log in
Since QSystemTrayIcon still inherits from QObject, it still cannot process events intended for QWidget. I think the option with a transparent widget is quite suitable. It is not possible to receive any events from the icon, such as show / hide, but you can still get its geometry through
QRect QSystemTrayIcon::geometry () const
void QObject::timerEvent ( QTimerEvent * event ) [virtual protected]
#include <QSystemTrayIcon>
class MySystemTrayIcon : public QSystemTrayIcon, QWidget
{
Q_OBJECT
public:
MySystemTrayIcon(QObject *parent = 0);
protected:
void timerEvent(QTimerEvent *event);
};
MySystemTrayIcon::MySystemTrayIcon(QObject *parent)
: QSystemTrayIcon(parent), QWidget(0)
{
startTimer(1000); // 1-second timer
}
void MySystemTrayIcon::timerEvent(QTimerEvent *event)
{
QWidget::setGeometry (QSystemTrayIcon::geometry());
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question