K
K
KOS_MOS2011-12-01 12:29:53
Icons
KOS_MOS, 2011-12-01 12:29:53

PyQt4 + Win7 - application icon is not removed from the taskbar when hide ()?

It is necessary that when the window is minimized, the application is hidden and the tray icon is shown.
The problem is that when I do self.hide() in hideEvent, the application icon does not disappear from the taskbar

class myWindow(QtGui.QMainWindow):<br/>
 <br/>
 def __init__(self, parent=None):<br/>
 QtGui.QWidget.__init__(self, parent=None)<br/>
 <br/>
 <br/>
 def hideEvent(self, event):<br/>
 self.hide()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey6661313, 2016-07-26
@Sergey6661313

it seems to me that after receiving the hide() signal, the hideEvent that you redefined to the hide() action is called - thus an endless loop is formed. And it turns out that the icon does not disappear because the application is generally frozen.

def hideEvent(self, event):
    QtGui.QMainWindow.hideEvent(self, event)  # или без self уже не помню.
    self.trayIcon = QtGui.QSystemTrayIcon(QtGui.QIcon(“myicon.png”),self) # где myicon.png картинка вашей иконки...
    self.trayIcon.show()

ready-made examples are already on your system:
Python\Lib\site-packages\PyQt4\examples
Python\Lib\site-packages\PyQt4\docs

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question