简体   繁体   中英

Set mouse pointer cursor on QTextEdit

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_())

“截屏”

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

self.status.setCursor(Qt.WaitCursor)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM