Results 1 to 2 of 2

Thread: PyQt5 QTextEdit limiting buffer

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2015
    Posts
    2
    Qt products
    Qt5
    Platforms
    MacOS X

    Default PyQt5 QTextEdit limiting buffer

    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.

  2. #2
    Join Date
    Nov 2015
    Posts
    2
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: PyQt5 QTextEdit limiting buffer

    The workaround I have in the meantime is to get the html into a string (since I do use the limited html) and do operations on the string. The problem with that is that I can't cut from anywhere when html is involved.

Similar Threads

  1. Limiting repaint events somehow
    By Marcaunon in forum Qt Programming
    Replies: 1
    Last Post: 15th February 2012, 14:31
  2. Replies: 3
    Last Post: 16th September 2009, 06:10
  3. Limiting the number of instances of one application
    By fullmetalcoder in forum Qt Programming
    Replies: 29
    Last Post: 16th May 2009, 15:53
  4. [QSettings] Why limiting to plain file or registry ?
    By lauranger in forum Qt Programming
    Replies: 8
    Last Post: 13th September 2006, 15:25
  5. Limiting values for custom designer properties
    By high_flyer in forum Qt Programming
    Replies: 4
    Last Post: 16th March 2006, 13:27

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.