The selection can be copied to the clipboard with copy(), or cut to the clipboard with cut(). If you want to set a selection in QPlainTextEdit just create one on a QTextCursor object and then make that cursor the visible cursor using setCursor(). You can retrieve the object that corresponds with the user-visible cursor using the textCursor() method. Selection of text is handled by the QTextCursor class, which provides functionality for creating selections, retrieving the text contents or deleting selections. While QPlainTextEdit does not support complex rich text rendering with tables and floats, it does support limited paragraph-based formatting that you may need in a log viewer.Īll the information about using QPlainTextEdit as a display widget also applies here. Text can be formatted in a limited way, either using a syntax highlighter (see below), or by appending html-formatted text with appendHtml(). The scrolling can be reduced with the centerOnScroll() property, making the log viewer even faster. The combination of setMaximumBlockCount() and appendPlainText() turns QPlainTextEdit into an efficient viewer for log text. If you want to limit the total number of paragraphs in a QPlainTextEdit, as it is for example useful in a log viewer, then you can use the maximumBlockCount property. The find() function can be used to find and select a given string within the text. If you use word wrap to the widget’s width WidgetWidth, you can specify whether to break on whitespace or anywhere with setWordWrapMode(). The setLineWrapMode() function is used to specify the kind of line wrap you want, WidgetWidth or NoWrap if you don’t want any wrapping. īy default, the text edit wraps words at whitespace to fit within the text edit widget. Text can be inserted using the QTextCursor class or using the convenience functions insertPlainText(), appendPlainText() or paste(). The text is set or replaced using setPlainText() which deletes the existing text and replaces it with the text passed to setPlainText().
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |