Text editor with tagged line numbers based on QPlainTextEdit

Referenceqt example key code CodeEditor.h file #ifndef CODEEDITOR_H #define CODEEDITOR_H #include <QPlainTextEdit> #include <QPaintEvent> #include <QContextMenuEvent> #include <QMouseEvent> #include <QMouseEvent> #include <QPainter> #include <QTextBlock> #include <QFontMetrics> #include <QTextCursor> #include <QTextBlockFormat> #include <QTextDocument> #include <QTextCodec> #include <QMenu> #include <QScrollBar> QString GetQString(QByteArray byteArray);//Prevent garbled characters enum TagType {<!– –> NUMBER=0, MARKROUND,//circle MARKBLOCK //block }; class TagLineNumberArea; class […]

[Qt controls QLineEdit, QPlainTextEdit, QTextEdit, QTextBrowser] usage and differences

Introduction QLineEdit, QPlainTextEdit, QTextEdit and QTextBrowser are all controls used for text input and display in Qt. There are some differences between them and they are suitable for different scenarios. The following is a brief introduction, differences and usage tips for these four categories: Function Name Function QLineEdit QLineEdit is a simple single-line text input […]

code_edit project example 08: pure code custom code component (QPlainTextEdit implementation)

Create class #ifndef MYCODEEDIT_H #defineMYCODEEDIT_H #include <QPlainTextEdit> // Global declaration, otherwise when MyCodeEdit uses this class, it will prompt error: unknown type name ‘LineNumberWidget’ class LineNumberWidget; class MyCodeEdit : public QPlainTextEdit { Q_OBJECT public: explicit MyCodeEdit(QWidget *parent = nullptr); // void lineNumberWidgetPaintEvent(QPaintEvent *event); //Mouse click event processing, called outside the class void lineNumberWidgetMousePessEvent(QMouseEvent *event); // […]

043.PyQt5_QPlainTextEdit_ multi-line plain text editor

QPlainTextEdit multi-line plain text editor Description QPlainText and QTextEdit have roughly similar functions, but are optimized for plain text processing Same as QTextEdit Applies to paragraphs and characters A paragraph is a formatted string that will automatically wrap to fit the width of the control By default, when reading plain text, a newline character represents […]

QTextEdit, QPlainTextEdit multi-line input box

QTextEdit, QPlainTextEdit multi-line input box QTextEdit and QPlainTextEdit are multi-line text input box components in PyQt6. This tutorial will introduce how to add QTextEdit and QPlainTextEdit multi-line text input boxes to the PyQt6 window, and implement basic applications such as modifying styles and reading input text. Quick tour: Differences between QTextEdit and QPlainTextEdit Add QTextEdit, […]