pyqt5 tooltip

Pyqt supports tool tips, they can be configured for widgets.
A tooltip is a hint in a graphical interface. Tooltips frequently appear when hovering the mouse over a widget (without clicking). Tooltips are not shown on mobile devices because there’s no mouse cursor.

Related course
Python Desktop Application Development with PyQt

Pyqt5 tooltip

A tooltip can be set using a widgets setTooltip method.

pybutton.setToolTip('This is a tooltip for the QPushButton widget')  

The setToolTip() method sets the tooltip message for a QtWidget.

Copy/paste example:

import sys
from PyQt5 import QtCore, QtWidgets
from PyQt5.QtWidgets import QMainWindow, QWidget, QPushButton
from PyQt5.QtCore import QSize    
     
class MainWindow(QMainWindow):
    def __init__(self):
        QMainWindow.__init__(self)
 
        self.setMinimumSize(QSize(300, 100))    
        self.setWindowTitle("PyQt tooltip example - pythonprogramminglanguage.com") 
        
        pybutton = QPushButton('Pyqt', self)
        pybutton.clicked.connect(self.clickMethod)
        pybutton.resize(100,32)
        pybutton.move(50, 20)        
        pybutton.setToolTip('This is a tooltip message.')  
        
    def clickMethod(self):
        print('PyQt')

    
if __name__ == "__main__":
    app = QtWidgets.QApplication(sys.argv)
    mainWin = MainWindow()
    mainWin.show()
    sys.exit( app.exec_() )

 

pyqt menu
pyqt5 message box

Leave a Reply

Your email address will not be published. Required fields are marked *