pyqt5 cursor button code example
Example 1: change cursor in pyqt5
your_widget.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
'''
https://doc.qt.io/qt-5/qcursor.html#a-note-for-x11-users
'''
import sys
from PyQt5 import QtCore, QtGui
from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QVBoxLayout
app = QApplication(sys.argv)
window = QWidget()
window.setGeometry(300, 300, 400, 200)
window.show()
v = QVBoxLayout()
l1 = QLabel("This label now has pointing hand cursor")
l2 = QLabel("but this label has default cursor")
l1.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
v.addWidget(l1)
v.addWidget(l2)
window.setLayout(v)
app.exec_()
Example 2: how to change cursor to hand in pyqt5
your_widget.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
import sys
from PyQt5 import QtCore, QtGui
from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QVBoxLayout
app = QApplication(sys.argv)
window = QWidget()
window.setGeometry(300, 300, 400, 200)
window.show()
v = QVBoxLayout()
l1 = QLabel("This label now has pointing hand cursor")
l2 = QLabel("but this label has default cursor")
l1.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
v.addWidget(l1)
v.addWidget(l2)
window.setLayout(v)
app.exec_()