凌的博客

您现在的位置是: 首页 > 学无止境 > python > 

python

PyQt5 QTextEdit 去除粘贴格式

2019-10-02 python 1776
class ActionText(QTextEdit):
    isEdit = False

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.signal = Signal()

    def mouseReleaseEvent(self, event):
        if self.isEdit == False:
            textCursor = self.textCursor()
            index = textCursor.position()
            # self.action_text.find(txt, QTextDocument.FindWholeWords)
            self.signal.indexTrigger.emit(index)

    def setColumnPos(self, index):
        textCursor = self.action_text.textCursor()
        textCursor.select(QTextCursor.LineUnderCursor)
        self.action_text.setTextCursor(textCursor)


    def insertFromMimeData(self, soc):
        if soc.hasText():
            self.textCursor().insertText(soc.text())  #去除粘贴格式


文章评论

0条评论