Set mouse pointer cursor on QTextEdit

Viewed 457

Aiming for Qt StyleSheet cursor: pointer; option but in PyQt5; as you can see by executing the code below, the cursor changes but only at the border of QTextEdit, not in the text area. I need it to also change in the text area.

import sys
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QApplication, QWidget, QHBoxLayout, QTextEdit

class MainWindow(QWidget):
    def __init__(self):
        super(MainWindow, self).__init__()
        self.myLayout = QHBoxLayout()
        self.status = QTextEdit()
        self.status.setStyleSheet("QTextEdit {min-width:500px;min-height:200px;border:15px solid green;}")
        self.status.setCursor(Qt.WaitCursor)
        self.status.setPlainText("test")

        self.myLayout.addWidget(self.status)
        self.setLayout(self.myLayout)

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

"screenshot"

1 Answers

Also that sets the Qt::WaitCursor cursor in the QTextEdit viewport:

self.status.setCursor(Qt.WaitCursor)
self.status.viewport().setCursor(Qt.WaitCursor)
Related