how to change cursor to hand in pyqt5

Solutions on MaxInterview for how to change cursor to hand in pyqt5 by the best coders in the world

showing results for - "how to change cursor to hand in pyqt5"
Ali
07 Oct 2020
1# simply use
2your_widget.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
3
4# Example :
5import sys
6from PyQt5 import QtCore, QtGui
7from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QVBoxLayout
8
9app = QApplication(sys.argv)
10
11window = QWidget()
12window.setGeometry(300, 300, 400, 200)
13window.show()
14
15v = QVBoxLayout()
16l1 = QLabel("This label now has pointing hand cursor")
17l2 = QLabel("but this label has default cursor")
18l1.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor)) # set cursor to pointing hand
19
20v.addWidget(l1)
21v.addWidget(l2)
22window.setLayout(v)
23
24app.exec_()