[PyQt] tooltips in menu: how?

massimo di stefano massimodisasha at yahoo.it
Wed Mar 18 18:40:28 GMT 2009


Hi Paolo,

i runned your code here on a mac osx, python2.5, qt-4.4.3, pyqt4.4.4
seems it works properly,
i can see tooltips :


-------------- next part --------------
A non-text attachment was scrubbed...
Name: img1.jp2
Type: image/jp2
Size: 4486 bytes
Desc: not available
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20090318/40f493a7/img1-0001.bin
-------------- next part --------------


-------------- next part --------------
A non-text attachment was scrubbed...
Name: img2.jp2
Type: image/jp2
Size: 11708 bytes
Desc: not available
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20090318/40f493a7/img2-0001.bin
-------------- next part --------------




Massimo Di Stefano
massimodisasha at yahoo.it

epifanio on   irc.freenode.net  /join gfoss







Il giorno 18/mar/09, alle ore 18:21, Paolo Milani ha scritto:

>
> Hi! :)
> I'm a newbie. I've searched in the docs, but I haven't found the  
> solution.
> I want to add tooltips to menu, but it doesn't work: tooltips are  
> not displayed.  Suggestions?
>
> my system: ubuntu linux 8.10 with kde 4..2 repository.
>
> Many thanks. This is the code:
>
>
>
> #!/usr/bin/env python
> # -*- coding: utf-8 -*-
> import sys
> from PyQt4 import QtCore, QtGui, uic
>
> class MainWindow(QtGui.QWidget):
>  def __init__(self, parent=None):
>    super(MainWindow, self).__init__(parent)
>    self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
>    self.setAttribute(QtCore.Qt.WA_GroupLeader)
>    self.menuI = QtGui.QPushButton("Menu")
>    self.menuI.setToolTip("Click here...")
>    self.menuI.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
>
>    mainLayout = QtGui.QHBoxLayout()
>    mainLayout.addWidget(self.menuI)
>    self.setLayout(mainLayout)
>    self.resize(49,40)
>    self.setWindowTitle("Qt menu")
>
>    self.clicAct0 = QtGui.QAction("0", self)
>    self.clicAct0.setToolTip("tooltip 0")
>    self.connect(self.clicAct0, QtCore.SIGNAL("triggered()"),  
> self.clic)
>
>    self.clicAct1 = QtGui.QAction("1", self)
>    self.clicAct1.setToolTip("tooltip 1")
>    self.connect(self.clicAct1, QtCore.SIGNAL("triggered()"),  
> self.clic)
>
>    self.clicAct2 = QtGui.QAction("2", self)
>    self.clicAct2.setToolTip("tooltip 2")
>    self.connect(self.clicAct2, QtCore.SIGNAL("triggered()"),  
> self.clic)
>
>    menu0 = QtGui.QMenu(self)
>    menu0.addAction(self.clicAct0)
>    menu0.addAction(self.clicAct1)
>    menu0.addAction(self.clicAct2)
>
>    menu1 = QtGui.QMenu(self)
>    menu1.setTitle("submenu")
>    menu1.setToolTip("tooltip submenu")
>
>    menu1_0 = QtGui.QAction("subentry",self)
>    menu1_0.setToolTip("tooltip subentry")
>
>    self.connect(menu1_0, QtCore.SIGNAL("triggered()"), self.clic)
>    menu1.addAction(menu1_0)
>    menu0.addMenu(menu1)
>    self.menuI.setMenu(menu0)
>
>  def clic(self):
>    print "clic"
>
>
> def main():
>  app = QtGui.QApplication(sys.argv)
>  locale = QtCore.QLocale.system().name()
>  appTranslator = QtCore.QTranslator()
>  app.setApplicationName(app.translate("main", "qtmenu"))
>
>  form = MainWindow()
>  form.show()
>  app.exec_()
>
> if __name__ == "__main__":
>  main()
>
>
>
>
>
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt



More information about the PyQt mailing list