【问题标题】:pyqt qtextedit move cursorpyqt qtextedit 移动光标
【发布时间】:2013-08-26 21:24:46
【问题描述】:

我正在使用带有搜索按钮的 Qtextedit。这是代码。

 format = QTextCharFormat()
 format.setBackground(QBrush(QColor("Gray")))
 regex = QRegExp(pattern)
 if (self.ui_log.checkBox_case.isChecked()==False):
    regex.setCaseSensitivity(False)
 pos = 0
 index = regex.indexIn(self.ui_log.log_textEdit.toPlainText(), pos)
 while (index != -1):
     cursor.setPosition(index)
     cursor.movePosition(QTextCursor.EndOfWord, 1)
     cursor.mergeCharFormat(format)
      pos = index + regex.matchedLength()
      self.ui_log.log_textEdit.moveCursor(??????)
      index = regex.indexIn(self.ui_log.log_textEdit.toPlainText(), pos)

Qtextedit 有一个滚动条,因为我在 qtextedit 中提供的输入文件很大..

搜索的文本被高亮显示,我如何通过提供单词索引来移动到搜索的文本?

【问题讨论】:

    标签: pyqt pyqt4


    【解决方案1】:

    不要移动现有的光标,而是设置一个新的:

    self.ui_log.log_textEdit.setTextCursor(cursor);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多