6#include <QStyleOptionFrame>
21 : QPlainTextEdit(parent)
24 handleCustomLayoutCreated();
38void ClearPlainTextEdit::handleTextChanged()
43void ClearPlainTextEdit::handleClearButtonClicked()
46 QTextCursor cursor(document());
47 cursor.select(QTextCursor::Document);
48 cursor.removeSelectedText();
51void ClearPlainTextEdit::handleCustomLayoutCreated()
55 const QStyle *
const s = style();
56 QStyleOptionFrame opt;
58 setContentsMarginsFromEditFieldRectAndFrameWidth(s->subElementRect(QStyle::SE_FrameContents, &opt,
this),
59 s->pixelMetric(QStyle::PM_DefaultFrameWidth, &opt, m_widget), s->pixelMetric(QStyle::PM_LayoutVerticalSpacing, &opt, m_widget));
60 connect(
this, &QPlainTextEdit::textChanged,
this, &ClearPlainTextEdit::handleTextChanged);
62 connect(verticalScrollBar(), &QScrollBar::actionTriggered,
this, &ClearPlainTextEdit::handleScroll);
63 connect(
this, &QPlainTextEdit::cursorPositionChanged,
this, &ClearPlainTextEdit::handleScroll);
66void ClearPlainTextEdit::handleScroll()
73 return document()->isEmpty();
~ClearPlainTextEdit() override
Destroys the clear plain text edit.
bool isCleared() const override
Returns whether the related widget is cleared.