I am using QSystemTrayIcon
for the first time, and it was trivial to implement. My code looks like this:
if(!connect(mTrayIcon, &QSystemTrayIcon::activated, this, &MiniStudio::onTrayActivated)) {
qWarning()<<"ERROR: could not connect QSystemTrayIcon";
}
mTrayIcon->setIcon(QIcon(":/icons/record.svg"));
mTrayIcon->setToolTip("Show MiniStudio controls");
mTrayIcon->setContextMenu(nullptr);
mTrayIcon->show();
As you probably understand from my code I don't want to display a context menu, I simply want a button in the tray that when clicked shows my application window.
The code sort of works, however, even if I specify a "nullptr" context menu, there still is a strange-looking box appearing under my tray icon whenever I click it, as if there is a context menu without any items in it (please see screenshot below).
So my questions are:
- Am I doing something wrong?
- How can I make the strange box go away?
- Is this a bug, or maybe a feature of Qt on my platform?
PS: I am developing this code for Ubuntu 16.04 amd64 but I think the answer to this question should be relevant to any platform.
NOTE: I have also tried just omitting the setContextMenu() call instead of calling it with nullptr
, and that didn't work either. The result was exactly the same.
Any input welcome,
Thank you!