I am facing an issue with QTextEdit. i am using eventFilters for QTextEdit. When i press keys in the numpad (0-9) in the QTextEdit it will auto compleate the sentense which is connected that number. For example

Everything is working fine but when i type a sentence and press the number 3 in numpad the text related to it is filled in QTextEdit but the cursor is moved to home. actually it is supposed to be the place where the sentence end.

Can anyone guide me how to deal with this.
Thanks and Regards,
Sudeepth Patinjarayil.
You just need to move the cursor to the end of the document, checkout this example:
#!/usr/bin/env python
#-*- coding:utf-8 -*-
from PyQt4 import QtGui, QtCore
class MyWindow(QtGui.QTextEdit):
def __init__(self, parent=None):
super(MyWindow, self).__init__(parent)
self.setPlainText("Hello!")
cursor = self.textCursor()
cursor.movePosition(QtGui.QTextCursor.End, QtGui.QTextCursor.MoveAnchor)
self.setTextCursor(cursor)
if __name__ == "__main__":
import sys
app = QtGui.QApplication(sys.argv)
app.setApplicationName('MyWindow')
main = MyWindow()
main.show()
sys.exit(app.exec_())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With