[PyQt] Application not hiding from taskbar
Mikael Modin
micke.modin at gmail.com
Mon Dec 6 12:13:44 GMT 2010
I figured out how to solve my little conundrum. My solution is so ugly
I'm ashamed but I can't figure out why self.hide() doesn't hide my
window in the first place. Here's the final code:
def hideEvent(self, event):
self.hide()
if ph.is_windows():
self.hidden = True
self.setWindowFlags(Qt.ToolTip)
def showEvent(self, event):
if ph.is_windows() and self.hidden:
self.setWindowFlags(Qt.Window)
self.hidden = False
self.show()
Kind regards,
Mikael
On 4 December 2010 00:40, Mikael Modin <micke.modin at gmail.com> wrote:
> Hi,
>
> I'm trying to implement minimize-to-tray but my application refuses to
> hide from taskbar. I've distilled the problematic code down to this
> little snippet, attached .ui-file.
>
> import sys, os
> from PyQt4 import uic
> from PyQt4.QtGui import QMainWindow, QApplication
>
> class MyClass(QMainWindow):
> def __init__(self, parent = None):
> QMainWindow.__init__(self, parent)
> self.ui = uic.loadUi(os.path.join("gui",
> "timeTrackerClientGUI.ui"), self)
> def hideEvent(self, event):
> self.hide()
>
> if __name__ == '__main__':
> app = QApplication(sys.argv)
> wnd = MyClass()
> wnd.show()
> app.exec_()
>
> According to http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qwidget.html#hideEvent
> I get a hideEvent when the user minimizes the window and that part
> works, but self.hide() doesn't hide my window from the taskbar. It's
> working fine in Linux, but in Windows 7 it refuses to hide. It looks
> like one icon hides but then another one pops up beside it, if I click
> quick enough you get this flickering effect I managed to catch in a
> screenshot, http://dl.dropbox.com/u/3184097/problem2.png
> I'm stumped, thought this would be simple to do.
>
> Kind regards
> Mikael Modin
>
More information about the PyQt
mailing list