我希望在特定行上单击鼠标光标时获取pyqt中textEdit的行号。请建议
答案 0 :(得分:0)
也许这会给你一个想法:
self.connect(self.ui.textEdit, QtCore.SIGNAL("cursorPositionChanged()"),self.lineNumber)
以后:
def lineNumber(self):
# we try to get the lineNumber on change of cursor position
theLineNumber = self.ui.textEdit.textCursor().blockNumber()
self.ui.label.setText('Ln : '+str(theLineNumber))