[PyQt] About QSystemTrayIcon, I Need some tips
david at boddie.org.uk
Mon Jul 23 23:59:36 BST 2007
On Mon Jul 23 23:29:37 BST 2007, Gustavo A. Díaz wrote:
> I've been progressing a lot lately with my app in PyQT (
> http://opencoffee.lnxteam.org), but like i am newbie in programming world
> and Python/QT, somethings cost me to understand. And i read the classes from
> the PyQT site, but i dont know c++ and i not pretend to learn it, is why i
> choose Python.
Fair enough. :-)
> I jave systray working perfectly. But i have a problem since Qt4.3 upgrade.
> Maybe is jusy my code:
> With Qt4.2 the same implementation of Systray in PyQT, when i was pressing
> in the close button of my APP (in the WM button) the app hides to the
> Since QT4.3, when i click on the close button, the app closes.
I can reproduce this problem with a minimal example:
from PyQt4.QtGui import *
if __name__ == "__main__":
app = QApplication(sys.argv)
tray = QSystemTrayIcon()
window = QWidget()
With Qt 4.2, it works as expected: the application keeps running after the
window is closed. With Qt 4.3, the application exits after the window is
closed. I'm not sure that this change is intentional, but I'm also not
sure whether the Qt 4.2 behaviour was ever guaranteed to work.
You might find it useful to see if anyone has reported a similar bug via
the Trolltech Task Tracker (when it's available again later):
If you're the first person to encounter this, please consider reporting it
so that it can be officially fixed, scheduled for a later release, or
> How i could fix this? or what do i need to add to my code to work correctly?
I was slightly surprised to see that the System Tray Icon example manages
this by making its only window ignore the close event and hide itself
This example hasn't been ported to Python yet, as far as I know, but it
should be easy to see what it does:
Look at the last code snippet on the page.
> Another thing i wan to implement is to click on the systray of the app and
> hide it, and click again to show it. I was trying but without success...
Hopefully, the above example will show you what you need to do.
More information about the PyQt