X-Git-Url: https://v.licheni.net/stack/code/dboxswitch.git/blobdiff_plain/d13b4666ed644a5bc5c0cee5657ad0b801ee5ad6..f19cd7df7f4f366e903c5160d6ca9eceb8555db5:/qmenutooltip.py diff --git a/qmenutooltip.py b/qmenutooltip.py new file mode 100644 index 0000000..486a3ad --- /dev/null +++ b/qmenutooltip.py @@ -0,0 +1,15 @@ +#!/bin/python + +from PyQt4 import QtGui, QtCore +class QMenuToolTip(QtGui.QMenu): + """ Implements a QMenu where it is possible to set a ToolTip and display it on mouse hover """ + def __init__(self, parent=None): + QtGui.QMenu.__init__(self, parent) + + def event(self, e): + if e.type() == QtCore.QEvent.ToolTip: + if not self.activeAction() is None: + QtGui.QToolTip.showText(e.globalPos(), self.activeAction().toolTip()) + else: + QtGui.QToolTip.hideText() + return QtGui.QMenu.event(self, e)