I am trying to code context menu similar to the one Dropbox has:
I thought that the best way to do this is to style QMenu attached to the QSystemTrayIcon:
class canvas : public QMenu
{
Q_OBJECT
public:
canvas(QObject* parent = 0);
};
canvas::canvas(QObject* parent) : QMenu()
{
setStyleSheet("QMenu{background-color:#00ff00;}");
}
class tray_icon : public QSystemTrayIcon
{
Q_OBJECT
public:
tray_icon(canvas* a_canvas, QObject* parent = 0);
};
tray_icon::tray_icon(canvas* a_canvas, QObject* parent) : QSystemTrayIcon(parent)
{
setContextMenu(a_canvas);
}
But for some reason QMenu does not react to the setStyleSheet call and it stays the same.
I have couple questions:
- What I am doing wrong in this situation (why the background colour is not set to green).
- Is QMenu the right tool to build dropdowns like that (maybe I should use some other widget). How Dropbox made such a menu?
Thank you!