

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. Text can be inserted using the QTextCursor class or using the convenience functions insertPlainText(), appendPlainText() or paste().īy default, the text edit wraps words at whitespace to fit within the text edit widget. The text is set or replaced using setPlainText() which deletes the existing text and replaces it with the text passed to setPlainText(). It can be changed through the viewport()'s cursor property. The shape of the mouse cursor on a QPlainTextEdit is Qt::IBeamCursor by default. Each character within a paragraph has its own attributes, for example, font and color. Paragraphs are separated by hard line breaks. A document consists of zero or more paragraphs. By default when reading plain text, one newline signifies a paragraph. A paragraph is a formatted string which is word-wrapped to fit into the width of the widget. QPlainTextEdit works on paragraphs and characters. QPlainText uses very much the same technology and concepts as QTextEdit, but is optimized for plain text handling. It is optimized to handle large documents and to respond quickly to user input. QPlainTextEdit is an advanced viewer/editor supporting plain text. ScrollContentsBy(int dx, int dy) overrideĭetailed Description Introduction and Concepts MouseReleaseEvent(QMouseEvent * e) override MousePressEvent(QMouseEvent * e) override MouseDoubleClickEvent(QMouseEvent * e) override InputMethodEvent(QInputMethodEvent * e) override SetWordWrapMode(QTextOption::WrapMode policy)ĬontextMenuEvent(QContextMenuEvent * event) overrideĭragEnterEvent(QDragEnterEvent * e) overrideĭragLeaveEvent(QDragLeaveEvent * e) overrideĭragMoveEvent(QDragMoveEvent * e) override SetTextInteractionFlags(Qt::TextInteractionFlags flags) SetTextCursor(const QTextCursor & cursor) SetPlaceholderText(const QString & placeholderText) SetLineWrapMode(QPlainTextEdit::LineWrapMode mode) SetExtraSelections(const QList & selections)

SetCurrentCharFormat(const QTextCharFormat & format) MoveCursor(QTextCursor::MoveOperation operation, QTextCursor::MoveMode mode = QTextCursor::MoveAnchor) MergeCurrentCharFormat(const QTextCharFormat & modifier) LoadResource(int type, const QUrl & name) QPlainTextEdit(QWidget * parent = nullptr)ĬreateStandardContextMenu(const QPoint & position)ĬursorForPosition(const QPoint & pos) constĬursorRect(const QTextCursor & cursor) constįind(const QString & exp, QTextDocument::FindFlags options = QTextDocument::FindFlags())įind(const QRegularExpression & exp, QTextDocument::FindFlags options = QTextDocument::FindFlags()) If you plan to support only plain texts, then QPlainTextEdit is the right choice.QPlainTextEdit(const QString & text, QWidget * parent = nullptr) Also the way text is formatted is simpler. So the difference is that QPlainTextEdit is optimized for handling plain text, and can be used even with very large plain text files. It also makes for aįast log viewer (see setMaximumBlockCount()). The editor with line wrap enabled in real time. Possible to handle significantly larger documents, and still resize Respectively paragraph-by-paragraph scrolling approach. Replaces a pixel-exact height calculation with a line-by-line The plain textĭocument layout does not support tables nor embedded frames, and Simplified text layout called QPlainTextDocumentLayout on the textĭocument (see QTextDocument::setDocumentLayout()). Its performanceīenefits over QTextEdit stem mostly from using a different and Technology that is behind QTextEdit and QTextDocument. QPlainTextEdit is a thin class, implemented by using most of the Has its own attributes, for example, font and color. ParagraphsĪre separated by hard line breaks. By default when reading plain text, one newline signifies a A paragraph is aįormatted string which is word-wrapped to fit into the width of the QTextEdit, but is optimized for plain text handling. QPlainText uses very much the same technology and concepts as Is optimized to handle large documents and to respond quickly to user
