1
저는 PySide로 시나리오 작성 응용 프로그램을 쓰고 있습니다. 내가 원하는 것은 사용자가 타이핑하는 동안 문자를 대문자로 바꾸는 것이다.텍스트 편집 항상 대문자
다음 코드는 문자를 추가 할 때마다 "최대 재귀 수준을 초과했습니다"라는 런타임 오류를 제공합니다. 나는 그것이 의미하는 바를 얻는다. 왜 그것이 일어나고 있는가?하지만 다른 방법이 있는가?
self.cursor = self.recipient.textCursor()
self.cursor.movePosition(QTextCursor.StartOfLine)
self.cursor.movePosition(QTextCursor.EndOfLine, QTextCursor.KeepAnchor)
self.curtext = self.cursor.selectedText()
if len(self.curtext) > len(self.prevText):
self.cursor.insertText(self.curtext.upper())
self.cursor.clearSelection()
self.prevText = self.curtext
위의 코드는 텍스트 편집 위젯의 텍스트가 변경 될 때마다 실행됩니다. if 문은 사용자가 텍스트를 삽입하지 않을 때 코드가 실행되는 것을 방지합니다.
http://stackoverflow.com/questions/19038897/making-a-qtextedit-capital에서 영감 : 그리고 당신은
가예 ... 밑줄 또는 굵은 텍스트를 만드는 등의 with it 훨씬 더 많은 일을 할 수 있습니다 – Trilarion