pyqt5 tooltip

A tooltip is a hint in a graphical interface.

Tooltips frequently appear when hovering the mouse over a widget (without clicking). Pyqt supports tool tips, they can be configured for widgets.

pyqt tooltip

Related course:

Note: Tooltips are not shown on mobile devices because there’s no mouse cursor.

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):
        self.setMinimumSize(QSize(300, 100))    
        self.setWindowTitle("PyQt tooltip example -") 
        pybutton = QPushButton('Pyqt', self)
        pybutton.move(50, 20)        
        pybutton.setToolTip('This is a tooltip message.')  
    def clickMethod(self):

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

Previous Post
Next Post

Leave a Reply

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