Is it possible to use PyQt5 to limit the number of lines in QTextEdit? I read about setMaximumBlockCount but can't seem to figure out how to actually use it on QTextEdit. Would anyone have an example they could give me? Here's a sample code I would like to use to do something like that...

Qt Code:
  1. import sys
  2. from PyQt5.QtWidgets import (QMainWindow, QTextEdit, QApplication, QLineEdit,
  3.  
  4. class Example(QMainWindow):
  5. def __init__(self):
  6. super().__init__()
  7. self.ex_frame = QFrame(self)
  8. self.ex_frame.setObjectName("ex_frame")
  9.  
  10. self.ex_out = QTextEdit(self.ex_frame)
  11. self.ex_out.setReadOnly(True)
  12. self.ex_out.setObjectName("ex_out")
  13. self.ex_in = QLineEdit(self.ex_frame)
  14. self.ex_in.setFocus(True)
  15. self.ex_in.setObjectName("ex_in")
  16. self.ex_in.returnPressed.connect(self.execute_command)
  17. vbox = QVBoxLayout(self.ex_frame)
  18. vbox.addWidget(self.ex_out)
  19. vbox.addWidget(self.ex_in)
  20. self.setCentralWidget(self.ex_frame)
  21.  
  22. self.setGeometry(300, 300, 720, 480)
  23. self.setWindowTitle('Example')
  24. self.show()
  25.  
  26. def execute_command(self):
  27. self.ex_out.append(self.ex_in.text())
  28. self.ex_in.setText('')
  29.  
  30. if __name__ == '__main__':
  31. app = QApplication(sys.argv)
  32. Ex = Example()
  33. sys.exit(app.exec_())
To copy to clipboard, switch view to plain text mode 

Any help would be appreciated. Thanks.