8#if QT_CONFIG(textbrowser)
16#if QT_CONFIG(draganddrop)
25#if QT_CONFIG(accessibility)
28#include "private/qtextdocumentlayout_p.h"
30#include "private/qtextdocument_p.h"
32#include "private/qwidgettextcontrol_p.h"
37#include <private/qapplication_p.h>
46#if defined (Q_OS_ANDROID)
49 return !textedit->isReadOnly();
62 return ed->createMimeDataFromSelection();
68 return ed->canInsertFromMimeData(
source);
75 ed->insertFromMimeData(
source);
78 auto *ed = qobject_cast<QTextEdit *>(
parent());
82 QUrl resolvedName = ed->d_func()->resolveUrl(
name);
83 return ed->loadResource(
type, resolvedName);
90 lineWrap(
QTextEdit::WidgetWidth), lineWrapColumnOrWidth(0),
91 wordWrap(
QTextOption::WrapAtWordBoundaryOrAnywhere), clickCausedFocus(0)
114 listFmt.setIndent(blockFmt.indent() + 1);
116 blockFmt.setIndent(0);
117 cursor.setBlockFormat(blockFmt);
119 cursor.createList(listFmt);
143 q, [
q]() {
q->updateMicroFocus(); }),
157 q, [
q]() {
q->updateMicroFocus(); }),
173 hbar->setSingleStep(20);
174 vbar->setSingleStep(20);
177 q->setMouseTracking(
true);
178 q->setAcceptDrops(
true);
209 emit q->cursorPositionChanged();
210#if QT_CONFIG(accessibility)
211 QAccessibleTextCursorEvent
event(
q,
q->textCursor().position());
212 QAccessible::updateAccessibility(&
event);
221 if (block.
isValid() && !
q->isReadOnly()) {
244 moved =
cursor.movePosition(op, moveMode);
245 }
while (moved && distance < viewport->
height());
259#if QT_CONFIG(scrollbar)
268 docSize = tlayout->dynamicDocumentSize().toSize();
269 int percentageDone = tlayout->layoutStatus();
271 if (percentageDone > 0)
272 docSize.
setHeight(docSize.height() * 100 / percentageDone);
274 docSize =
layout->documentSize().toSize();
295 for (
int i = 0;
i < 4; ++
i) {
296 hbar->setRange(0, docSize.width() - viewportSize.
width());
297 hbar->setPageStep(viewportSize.
width());
299 vbar->setRange(0, docSize.height() - viewportSize.
height());
300 vbar->setPageStep(viewportSize.
height());
311 _q_showOrHideScrollBars();
313 const QSize oldViewportSize = viewportSize;
314 const QSize oldDocSize = docSize;
318 if (viewportSize.
width() != oldViewportSize.width())
321 docSize = documentSize(
control);
322 if (viewportSize == oldViewportSize && docSize == oldDocSize)
333 if ((vbar->isVisible() && vbar->maximum() <
rect.bottom())
334 || (hbar->isVisible() && hbar->maximum() <
rect.right()))
336 const int visibleWidth =
viewport->width();
337 const int visibleHeight =
viewport->height();
338 const bool rtl = q_func()->isRightToLeft();
342 hbar->setValue(hbar->maximum() -
rect.x());
344 hbar->setValue(
rect.x());
347 hbar->setValue(hbar->maximum() - (
rect.x() +
rect.width() - visibleWidth));
349 hbar->setValue(
rect.x() +
rect.width() - visibleWidth);
353 vbar->setValue(
rect.y());
355 vbar->setValue(
rect.y() +
rect.height() - visibleHeight);
627 : QAbstractScrollArea(dd, parent)
661 return d->control->textCursor().charFormat().fontPointSize();
672 return d->control->textCursor().charFormat().fontFamilies().toStringList().value(0,
QString());
683 return d->control->textCursor().charFormat().fontWeight();
695 return d->control->textCursor().charFormat().fontUnderline();
707 return d->control->textCursor().charFormat().fontItalic();
718 return d->control->textCursor().charFormat().foreground().color();
731 const QBrush &
brush =
d->control->textCursor().charFormat().background();
743 return d->control->textCursor().charFormat().font();
759 d->control->setTextCursor(
cursor);
760 d->relayoutDocument();
771 return d->control->textCursor().blockFormat().alignment();
787 d->updateDefaultTextOption();
788 d->relayoutDocument();
794 return d->control->document();
813 return d->placeholderText;
821 if (
d->control->document()->isEmpty())
822 d->viewport->update();
843 d->control->setTextCursor(
cursor);
854 return d->control->textCursor();
998#ifndef QT_NO_CLIPBOARD
1043 d->control->paste();
1063 d->control->clear();
1075 d->control->selectAll();
1083 switch (e->
type()) {
1086 d->sendControlEvent(e);
1092#ifndef QT_NO_CONTEXTMENU
1099 const bool result = QAbstractScrollArea::event(&ce);
1105#ifdef QT_KEYPAD_NAVIGATION
1106 case QEvent::EnterEditFocus:
1107 case QEvent::LeaveEditFocus:
1108 if (QApplicationPrivate::keypadNavigationEnabled())
1109 d->sendControlEvent(e);
1115 return QAbstractScrollArea::event(e);
1124 if (e->
timerId() ==
d->autoScrollTimer.timerId()) {
1125 QRect visible =
d->viewport->rect();
1128 pos =
d->autoScrollDragPos;
1133 pos =
d->viewport->mapFromGlobal(globalPos);
1139 int delta =
qMax(deltaX, deltaY);
1143 int timeout = 4900 / (delta * delta);
1144 d->autoScrollTimer.start(
timeout,
this);
1147 d->vbar->triggerAction(
pos.y() < visible.
center().y() ?
1151 d->hbar->triggerAction(
pos.x() < visible.
center().x() ?
1156#ifdef QT_KEYPAD_NAVIGATION
1157 else if (e->
timerId() ==
d->deleteAllTimer.timerId()) {
1158 d->deleteAllTimer.stop();
1182 d->control->setPlainText(
text);
1183 d->preferRichText =
false;
1196 return d->control->toPlainText();
1221#ifndef QT_NO_TEXTHTMLPARSER
1225 d->control->setHtml(
text);
1226 d->preferRichText =
true;
1232 return d->control->toHtml();
1236#if QT_CONFIG(textmarkdownreader) && QT_CONFIG(textmarkdownwriter)
1272#if QT_CONFIG(textmarkdownreader)
1273void QTextEdit::setMarkdown(
const QString &markdown)
1276 d->control->setMarkdown(markdown);
1280#if QT_CONFIG(textmarkdownwriter)
1281QString QTextEdit::toMarkdown(QTextDocument::MarkdownFeatures features)
const
1284 return d->control->toMarkdown(features);
1294#ifdef QT_KEYPAD_NAVIGATION
1297 if (QApplicationPrivate::keypadNavigationEnabled()) {
1300 setEditFocus(!hasEditFocus());
1302 if (!hasEditFocus())
1308 || !
cursor.hasSelection() || charFmt.anchorHref().isEmpty()) {
1318 if (!QApplicationPrivate::keypadNavigationEnabled()
1319 || (QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus())) {
1325 if (QApplicationPrivate::keypadNavigationEnabled()) {
1327 if (e->
text()[0].isPrint())
1338#ifndef QT_NO_SHORTCUT
1340 Qt::TextInteractionFlags tif =
d->control->textInteractionFlags();
1375 d->sendControlEvent(e);
1386 QAbstractScrollArea::keyPressEvent(e);
1396 if (
cursor.atBlockStart()
1400 && (!
cursor.currentList())) {
1402 d->createAutoBulletList();
1408 d->sendControlEvent(e);
1409#ifdef QT_KEYPAD_NAVIGATION
1414 if (QApplicationPrivate::keypadNavigationEnabled()) {
1423 if (QApplicationPrivate::keypadNavigationEnabled()) {
1425 setEditFocus(
false);
1427 }
else if (!
d->deleteAllTimer.isActive()) {
1429 d->deleteAllTimer.start(750,
this);
1449 d->handleSoftwareInputPanel();
1450#ifdef QT_KEYPAD_NAVIGATION
1451 if (QApplicationPrivate::keypadNavigationEnabled()) {
1453 &&
d->deleteAllTimer.isActive()) {
1454 d->deleteAllTimer.stop();
1461 }
else if (
cursor.atBlockStart() && blockFmt.indent() > 0) {
1462 blockFmt.setIndent(blockFmt.indent() - 1);
1463 cursor.setBlockFormat(blockFmt);
1465 cursor.deletePreviousChar();
1501 && alignmentProperty.userType() == QMetaType::Bool
1502 && !alignmentProperty.toBool()) {
1504 d->adjustScrollbars();
1511 d->relayoutDocument();
1513 d->adjustScrollbars();
1525 tlayout->setFixedColumnWidth(-1);
1531 lastUsedSize = tlayout->dynamicDocumentSize().toSize();
1533 lastUsedSize =
layout->documentSize().toSize();
1546 if (alignmentProperty.userType() == QMetaType::Bool && !alignmentProperty.toBool()) {
1560 usedSize = tlayout->dynamicDocumentSize().toSize();
1562 usedSize =
layout->documentSize().toSize();
1580 if (lastUsedSize.isValid()
1581 && !vbar->isHidden()
1582 &&
viewport->width() < lastUsedSize.width()
1583 && usedSize.height() < lastUsedSize.height()
1584 && usedSize.height() <=
viewport->height())
1597 r.translate(xOffset, yOffset);
1649 if (
opt.wrapMode() != oldWrapMode)
1658#ifdef QT_KEYPAD_NAVIGATION
1659 if (QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus())
1662 d->sendControlEvent(e);
1672 d->sendControlEvent(e);
1676 const QRect visible =
d->viewport->rect();
1678 d->autoScrollTimer.stop();
1679 else if (!
d->autoScrollTimer.isActive())
1680 d->autoScrollTimer.start(100,
this);
1689 d->sendControlEvent(e);
1691 d->autoScrollTimer.stop();
1695 d->handleSoftwareInputPanel(e->
button(),
d->clickCausedFocus);
1696 d->clickCausedFocus = 0;
1704 d->sendControlEvent(e);
1714 return QAbstractScrollArea::focusNextPrevChild(
next);
1717#ifndef QT_NO_CONTEXTMENU
1736 d->sendControlEvent(e);
1740#if QT_CONFIG(draganddrop)
1743void QTextEdit::dragEnterEvent(QDragEnterEvent *e)
1747 d->sendControlEvent(e);
1752void QTextEdit::dragLeaveEvent(QDragLeaveEvent *e)
1756 d->autoScrollTimer.stop();
1757 d->sendControlEvent(e);
1762void QTextEdit::dragMoveEvent(QDragMoveEvent *e)
1765 d->autoScrollDragPos = e->position().toPoint();
1766 if (!
d->autoScrollTimer.isActive())
1767 d->autoScrollTimer.start(100,
this);
1768 d->sendControlEvent(e);
1773void QTextEdit::dropEvent(QDropEvent *e)
1777 d->autoScrollTimer.stop();
1778 d->sendControlEvent(e);
1788#ifdef QT_KEYPAD_NAVIGATION
1790 && QApplicationPrivate::keypadNavigationEnabled()
1794 d->sendControlEvent(e);
1807 if (isRightToLeft())
1809 d->viewport->scroll(dx, dy);
1839 case QMetaType::QRectF:
1842 case QMetaType::QPointF:
1845 case QMetaType::QRect:
1848 case QMetaType::QPoint:
1856 switch (
v.userType()) {
1857 case QMetaType::QRectF:
1859 case QMetaType::QPointF:
1861 case QMetaType::QRect:
1862 return v.toRect().translated(
offset.toPoint());
1863 case QMetaType::QPoint:
1864 return v.toPoint() +
offset.toPoint();
1877 d->clickCausedFocus = 1;
1879 QAbstractScrollArea::focusInEvent(e);
1880 d->sendControlEvent(e);
1888 QAbstractScrollArea::focusOutEvent(e);
1889 d->sendControlEvent(e);
1897 if (!
d->anchorToScrollToWhenVisible.isEmpty()) {
1899 d->anchorToScrollToWhenVisible.clear();
1900 d->showCursorOnInitialShow =
false;
1901 }
else if (
d->showCursorOnInitialShow) {
1902 d->showCursorOnInitialShow =
false;
1912 QAbstractScrollArea::changeEvent(e);
1915 d->control->document()->setDefaultFont(
font());
1917 if (!isActiveWindow())
1918 d->autoScrollTimer.stop();
1922 d->sendControlEvent(e);
1926 d->sendControlEvent(e);
1932#if QT_CONFIG(wheelevent)
1933void QTextEdit::wheelEvent(QWheelEvent *e)
1938 float delta = e->angleDelta().y() / 120.f;
1943 QAbstractScrollArea::wheelEvent(e);
1948#ifndef QT_NO_CONTEXTMENU
1961 return d->control->createStandardContextMenu(
QPointF(),
this);
1977 return d->control->createStandardContextMenu(
position,
this);
1987 return d->control->cursorForPosition(
d->mapToContents(
pos));
2001 r.
translate(-
d->horizontalOffset(),-
d->verticalOffset());
2012 QRect r =
d->control->cursorRect().toRect();
2013 r.
translate(-
d->horizontalOffset(),-
d->verticalOffset());
2025 return d->control->anchorAt(
d->mapToContents(
pos));
2046 return d->control->overwriteMode();
2052 d->control->setOverwriteMode(overwrite);
2072 return d->control->document()->defaultTextOption().tabStopDistance();
2082 d->control->document()->setDefaultTextOption(
opt);
2094 return d->control->cursorWidth();
2100 d->control->setCursorWidth(
width);
2117 return d->control->acceptRichText();
2123 d->control->setAcceptRichText(accept);
2158 d->control->setExtraSelections(selections);
2170 return d->control->extraSelections();
2186 return d->control->QWidgetTextControl::createMimeDataFromSelection();
2201 return d->control->QWidgetTextControl::canInsertFromMimeData(
source);
2216 d->control->QWidgetTextControl::insertFromMimeData(
source);
2241#if QT_CONFIG(textbrowser)
2242 if (qobject_cast<QTextBrowser *>(
this))
2248 d->control->setTextInteractionFlags(
flags);
2267 d->control->setTextInteractionFlags(
flags);
2273 return d->control->textInteractionFlags();
2287 d->control->mergeCurrentCharFormat(modifier);
2299 d->control->setCurrentCharFormat(
format);
2308 return d->control->currentCharFormat();
2326 return d->autoFormatting;
2332 d->autoFormatting = features;
2346 d->control->insertPlainText(
text);
2362#ifndef QT_NO_TEXTHTMLPARSER
2366 d->control->insertHtml(
text);
2382 d->anchorToScrollToWhenVisible =
name;
2387 const int newPosition =
qRound(
p.y());
2388 if (
d->vbar->maximum() < newPosition )
2389 d->adjustScrollbars();
2390 d->vbar->setValue(newPosition);
2425 const float newSize =
f.pointSizeF() +
range;
2428 f.setPointSizeF(newSize);
2445 d->control->moveCursor(operation,
mode);
2455 return d->control->canPaste();
2466#ifndef QT_NO_PRINTER
2470 d->control->print(printer);
2486 return d->tabChangesFocus;
2492 d->tabChangesFocus =
b;
2526 if (
d->lineWrap ==
wrap)
2529 d->updateDefaultTextOption();
2530 d->relayoutDocument();
2551 return d->lineWrapColumnOrWidth;
2557 d->lineWrapColumnOrWidth =
w;
2558 d->relayoutDocument();
2579 if (
mode ==
d->wordWrap)
2582 d->updateDefaultTextOption();
2593 return d->control->find(exp, options);
2612#if QT_CONFIG(regularexpression)
2616 return d->control->find(exp, options);
2675#ifndef QT_NO_TEXTHTMLPARSER
2698 const bool atBottom =
isReadOnly() ?
d->verticalOffset() >=
d->vbar->maximum() :
2699 d->control->textCursor().atEnd();
2700 d->control->append(
text);
2702 d->vbar->setValue(
d->vbar->maximum());
2712 d->control->ensureCursorVisible();
2738#include "moc_qtextedit.cpp"
void setPaintDevice(QPaintDevice *device)
Sets the paint device used for rendering the document's layout to the given device.
const QColor & color() const
Returns the brush color.
The QColor class provides colors based on RGB, HSV or CMYK values.
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
static QPoint pos()
Returns the position of the cursor (hot spot) of the primary screen in global screen coordinates.
virtual void setAccepted(bool accepted)
Type type() const
Returns the event type.
void ignore()
Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false).
void accept()
Sets the accept flag of the event object, the equivalent of calling setAccepted(true).
The QFocusEvent class contains event parameters for widget focus events.
Qt::FocusReason reason() const
Returns the reason for this focus event.
static QInputMethod * inputMethod()
returns the input method.
The QKeyEvent class describes a key event.
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately after the event occurred.
QString text() const
Returns the Unicode text that this key generated.
bool isAutoRepeat() const
Returns true if this event comes from an auto-repeating key; returns false if it comes from an initia...
int key() const
Returns the code of the key that was pressed or released.
void remove(qsizetype i, qsizetype n=1)
Qt::MouseEventSource source() const
static QMetaObject::Connection connect(const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiverPrivate, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
QObject * parent() const
Returns a pointer to the parent object.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
\threadsafe
QVariant property(const char *name) const
Returns the value of the object's name property.
The QPaintEvent class contains event parameters for paint events.
const QRect & rect() const
Returns the rectangle that needs to be updated.
The QPainter class performs low-level painting on widgets and other paint devices.
const QBrush & placeholderText() const
\inmodule QtCore\reentrant
constexpr QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
QRect toAlignedRect() const noexcept
constexpr QRectF translated(qreal dx, qreal dy) const noexcept
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis,...
constexpr qreal top() const noexcept
Returns the y-coordinate of the rectangle's top edge.
constexpr bool isValid() const noexcept
Returns true if the rectangle is valid, otherwise returns false.
QRectF intersected(const QRectF &other) const noexcept
\inmodule QtCore\reentrant
constexpr void adjust(int x1, int y1, int x2, int y2) noexcept
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
constexpr int height() const noexcept
Returns the height of the rectangle.
constexpr int bottom() const noexcept
Returns the y-coordinate of the rectangle's bottom edge.
constexpr int top() const noexcept
Returns the y-coordinate of the rectangle's top edge.
bool contains(const QRect &r, bool proper=false) const noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
constexpr int left() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr void translate(int dx, int dy) noexcept
Moves the rectangle dx along the x axis and dy along the y axis, relative to the current position.
constexpr int width() const noexcept
Returns the width of the rectangle.
constexpr QPoint center() const noexcept
Returns the center point of the rectangle.
constexpr int right() const noexcept
Returns the x-coordinate of the rectangle's right edge.
\inmodule QtCore \reentrant
The QResizeEvent class contains event parameters for resize events.
const QSize & oldSize() const
Returns the old size of the widget.
const QSize & size() const
Returns the new size of the widget.
The QShowEvent class provides an event that is sent when a widget is shown.
QPointF position() const
Returns the position of the point in this event, relative to the widget or item that received the eve...
Qt::MouseButton button() const
Returns the button that caused the event.
Qt::MouseButtons buttons() const
Returns the button state when the event was generated.
bool isNull() const noexcept
Returns true if both the width and height are 0.0 (ignoring the sign); otherwise returns false.
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
constexpr void setHeight(int h) noexcept
Sets the height to the given height.
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
qsizetype size() const noexcept
Returns the number of characters in this string.
const QChar at(qsizetype i) const
Returns the character at the given index position in the string.
MarkerType marker() const
void setAlignment(Qt::Alignment alignment)
Sets the paragraph's alignment.
QTextBlockFormat blockFormat() const
Returns the QTextBlockFormat that describes block-specific properties.
bool isValid() const
Returns true if this text block is valid; otherwise returns false.
void setFontFamilies(const QStringList &families)
void setFontPointSize(qreal size)
Sets the text format's font size.
void setFontUnderline(bool underline)
If underline is true, sets the text format's font to be underlined; otherwise it is displayed non-und...
void setFontItalic(bool italic)
If italic is true, sets the text format's font to be italic; otherwise the font will be non-italic.
void setFontWeight(int weight)
Sets the text format's font weight to weight.
void setFont(const QFont &font, FontPropertiesInheritanceBehavior behavior=FontPropertiesAll)
\reentrant \inmodule QtGui
MoveMode
\value MoveAnchor Moves the anchor to the same position as the cursor itself.
MoveOperation
\value NoMove Keep the cursor where it is
\reentrant \inmodule QtGui
bool isEmpty() const
Returns true if the document is empty; otherwise returns false.
void setDefaultTextOption(const QTextOption &option)
QAbstractTextDocumentLayout * documentLayout() const
Returns the document layout for this document.
QSizeF pageSize
the page size that should be used for laying out the document
QTextOption defaultTextOption() const
the default text option will be set on all \l{QTextLayout}s in the document.
void setDefaultFont(const QFont &font)
Sets the default font to use in the document layout.
void setPageSize(const QSizeF &size)
void setUndoRedoEnabled(bool enable)
virtual void insertFromMimeData(const QMimeData *source) override
virtual QMimeData * createMimeDataFromSelection() const override
QVariant loadResource(int type, const QUrl &name) override
virtual bool canInsertFromMimeData(const QMimeData *source) const override
QTextEditControl(QObject *parent)
QWidgetTextControl * control
void repaintContents(const QRectF &contentsRect)
QTextEdit::LineWrapMode lineWrap
void hoveredBlockWithMarkerChanged(const QTextBlock &block)
void pageUpDown(QTextCursor::MoveOperation op, QTextCursor::MoveMode moveMode)
Qt::CursorShape cursorToRestoreAfterHover
int horizontalOffset() const
int lineWrapColumnOrWidth
uint ignoreAutomaticScrollbarAdjustment
void ensureVisible(const QRectF &rect)
int verticalOffset() const
void createAutoBulletList()
void cursorPositionChanged()
std::array< QMetaObject::Connection, 13 > connections
uint showCursorOnInitialShow
void paint(QPainter *p, QPaintEvent *e)
void init(const QString &html=QString())
void updateDefaultTextOption()
QTextOption::WrapMode wordWrap
The QTextEdit class provides a widget that is used to edit and display both plain and rich text.
virtual void scrollContentsBy(int dx, int dy) override
\reimp
void ensureCursorVisible()
Ensures that the cursor is visible by scrolling the text edit if necessary.
virtual void paintEvent(QPaintEvent *e) override
This event handler can be reimplemented in a subclass to receive paint events passed in event.
void redoAvailable(bool b)
This signal is emitted whenever redo operations become available (available is true) or unavailable (...
void setCursorWidth(int width)
virtual void resizeEvent(QResizeEvent *e) override
\reimp
void paste()
Pastes the text from the clipboard into the text edit at the current cursor position.
void setTextCursor(const QTextCursor &cursor)
Sets the visible cursor.
virtual void focusInEvent(QFocusEvent *e) override
\reimp
QString placeholderText
the editor placeholder text
void setTabChangesFocus(bool b)
qreal tabStopDistance
the tab stop distance in pixels
void zoomIn(int range=1)
Zooms in on the text by making the base font size range points larger and recalculating all font size...
int lineWrapColumnOrWidth
the position (in pixels or columns depending on the wrap mode) where text will be wrapped
QString fontFamily() const
Returns the font family of the current format.
virtual void showEvent(QShowEvent *) override
\reimp
virtual void mousePressEvent(QMouseEvent *e) override
\reimp
virtual bool focusNextPrevChild(bool next) override
\reimp
LineWrapMode
\value NoWrap \value WidgetWidth \value FixedPixelWidth \value FixedColumnWidth
virtual void mouseReleaseEvent(QMouseEvent *e) override
\reimp
bool find(const QString &exp, QTextDocument::FindFlags options=QTextDocument::FindFlags())
Finds the next occurrence of the string, exp, using the given options.
QVariant inputMethodQuery(Qt::InputMethodQuery property) const override
\reimp
QTextOption::WrapMode wordWrapMode() const
the mode QTextEdit will use when wrapping text by words
void setTextBackgroundColor(const QColor &c)
void setTextColor(const QColor &c)
Sets the text color of the current format to c.
void setLineWrapMode(LineWrapMode mode)
void setFontUnderline(bool b)
If underline is true, sets the current format to underline; otherwise sets the current format to non-...
virtual void contextMenuEvent(QContextMenuEvent *e) override
Shows the standard context menu created with createStandardContextMenu().
void currentCharFormatChanged(const QTextCharFormat &format)
This signal is emitted if the current character format has changed, for example caused by a change of...
QMenu * createStandardContextMenu()
\reimp
void insertHtml(const QString &text)
Convenience slot that inserts text which is assumed to be of html formatting at the current cursor po...
void setReadOnly(bool ro)
void setAutoFormatting(AutoFormatting features)
void undoAvailable(bool b)
This signal is emitted whenever undo operations become available (available is true) or unavailable (...
virtual void inputMethodEvent(QInputMethodEvent *) override
\reimp
void selectAll()
Selects all text.
void append(const QString &text)
Appends a new paragraph with text to the end of the text edit.
void zoomOut(int range=1)
Zooms out on the text by making the base font size range points smaller and recalculating all font si...
QColor textColor() const
Returns the text color of the current format.
void setText(const QString &text)
void setCurrentCharFormat(const QTextCharFormat &format)
Sets the char format that is be used when inserting new text to format by calling QTextCursor::setCha...
Qt::TextInteractionFlags textInteractionFlags
QTextCursor cursorForPosition(const QPoint &pos) const
returns a QTextCursor at position pos (in viewport coordinates).
bool acceptRichText
whether the text edit accepts rich text insertions by the user
void mergeCurrentCharFormat(const QTextCharFormat &modifier)
Merges the properties specified in modifier into the current character format by calling QTextCursor:...
LineWrapMode lineWrapMode
the line wrap mode
void setLineWrapColumnOrWidth(int w)
void copyAvailable(bool b)
This signal is emitted when text is selected or de-selected in the text edit.
QTextCharFormat currentCharFormat() const
Returns the char format that is used when inserting new text.
void moveCursor(QTextCursor::MoveOperation operation, QTextCursor::MoveMode mode=QTextCursor::MoveAnchor)
QColor textBackgroundColor() const
bool overwriteMode
whether text entered by the user will overwrite existing text
void textChanged()
This signal is emitted whenever the document's content changes; for example, when text is inserted or...
virtual QMimeData * createMimeDataFromSelection() const
This function returns a new MIME data object to represent the contents of the text edit's current sel...
virtual void doSetTextCursor(const QTextCursor &cursor)
bool tabChangesFocus
whether \uicontrol Tab changes focus or is accepted as input
bool fontUnderline() const
Returns true if the font of the current format is underlined; otherwise returns false.
QTextEdit(QWidget *parent=nullptr)
Constructs an empty QTextEdit with parent parent.
void setExtraSelections(const QList< ExtraSelection > &selections)
\variable QTextEdit::ExtraSelection::cursor A cursor that contains a selection in a QTextDocument
void copy()
Copies any selected text to the clipboard.
AutoFormatting autoFormatting
the enabled set of auto formatting features
void setPlainText(const QString &text)
Changes the text of the text edit to the string text.
virtual void keyReleaseEvent(QKeyEvent *e) override
\reimp
QTextCursor textCursor() const
Returns a copy of the QTextCursor that represents the currently visible cursor.
QRect cursorRect() const
returns a rectangle (in viewport coordinates) that includes the cursor of the text edit.
QString anchorAt(const QPoint &pos) const
Returns the reference of the anchor at position pos, or an empty string if no anchor exists at that p...
void setTextInteractionFlags(Qt::TextInteractionFlags flags)
void clear()
Deletes all the text in the text edit.
bool fontItalic() const
Returns true if the font of the current format is italic; otherwise returns false.
qreal fontPointSize() const
Returns the point size of the font of the current format.
virtual void keyPressEvent(QKeyEvent *e) override
\reimp
void setWordWrapMode(QTextOption::WrapMode policy)
void setCurrentFont(const QFont &f)
Sets the font of the current format to f.
virtual bool canInsertFromMimeData(const QMimeData *source) const
This function returns true if the contents of the MIME data object, specified by source,...
void setAlignment(Qt::Alignment a)
Sets the alignment of the current paragraph to a.
void setPlaceholderText(const QString &placeholderText)
virtual Q_INVOKABLE QVariant loadResource(int type, const QUrl &name)
Loads the resource specified by the given type and name.
void setOverwriteMode(bool overwrite)
virtual void timerEvent(QTimerEvent *e) override
void setFontItalic(bool b)
If italic is true, sets the current format to italic; otherwise sets the current format to non-italic...
virtual ~QTextEdit()
Destructor.
virtual void mouseMoveEvent(QMouseEvent *e) override
\reimp
void setFontPointSize(qreal s)
Sets the point size of the current format to s.
void setFontFamily(const QString &fontFamily)
Sets the font family of the current format to fontFamily.
void setFontWeight(int w)
Sets the font weight of the current format to the given weight, where the value used is in the range ...
QString toPlainText() const
QString QTextEdit::toPlainText() const.
Qt::Alignment alignment() const
Returns the alignment of the current paragraph.
void setAcceptRichText(bool accept)
QFont currentFont() const
Returns the font of the current format.
virtual void insertFromMimeData(const QMimeData *source)
This function inserts the contents of the MIME data object, specified by source, into the text edit a...
void setHtml(const QString &text)
virtual void mouseDoubleClickEvent(QMouseEvent *e) override
\reimp
void insertPlainText(const QString &text)
Convenience slot that inserts text at the current cursor position.
void zoomInF(float range)
void print(QPagedPaintDevice *printer) const
void scrollToAnchor(const QString &name)
Scrolls the text edit so that the anchor with the given name is visible; does nothing if the name is ...
virtual void changeEvent(QEvent *e) override
\reimp
void setDocument(QTextDocument *document)
void setTabStopDistance(qreal distance)
int fontWeight() const
Returns the font weight of the current format.
virtual bool event(QEvent *e) override
QTextDocument * document
the underlying document of the text editor.
void cut()
Copies the selected text to the clipboard and deletes it from the text edit.
virtual void focusOutEvent(QFocusEvent *e) override
\reimp
QList< ExtraSelection > extraSelections() const
void selectionChanged()
This signal is emitted whenever the selection changes.
void setForeground(const QBrush &brush)
Sets the foreground brush to the specified brush.
void setBackground(const QBrush &brush)
Sets the brush use to paint the document's background to the brush specified.
void setStyle(Style style)
Sets the list format's style.
WrapMode
This enum describes how text is wrapped in a document.
int timerId() const
Returns the unique timer identifier, which is the same identifier as returned from QObject::startTime...
QRectF toRectF() const
Returns the variant as a QRectF if the variant has userType() \l QMetaType::QRect or \l QMetaType::QR...
QTextCursor textCursor() const
void redoAvailable(bool b)
void setHtml(const QString &text)
void cursorPositionChanged()
virtual QMimeData * createMimeDataFromSelection() const
void setTextCursor(const QTextCursor &cursor, bool selectionClipboard=false)
virtual Q_INVOKABLE QVariant loadResource(int type, const QUrl &name)
void undoAvailable(bool b)
QRectF cursorRect(const QTextCursor &cursor) const
void updateRequest(const QRectF &rect=QRectF())
void blockMarkerHovered(const QTextBlock &block)
void drawContents(QPainter *painter, const QRectF &rect=QRectF(), QWidget *widget=nullptr)
void documentSizeChanged(const QSizeF &)
virtual void insertFromMimeData(const QMimeData *source)
void currentCharFormatChanged(const QTextCharFormat &format)
void visibilityRequest(const QRectF &rect)
virtual bool canInsertFromMimeData(const QMimeData *source) const
void setPalette(const QPalette &pal)
QTextDocument * document() const
void copyAvailable(bool b)
Combined button and popup list for selecting options.
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isRightToLeft(QStringView string) noexcept
@ ImInputItemClipRectangle
@ LinksAccessibleByKeyboard
@ TextSelectableByKeyboard
@ MouseEventNotSynthesized
Q_GUI_EXPORT bool mightBeRichText(QAnyStringView)
Returns true if the string text is likely to be rich text; otherwise returns false.
DBusConnection * connection
int qRound(qfloat16 d) noexcept
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
constexpr T qAbs(const T &t)
static bool contains(const QJsonArray &haystack, unsigned needle)
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * v
[13]
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLboolean GLboolean GLboolean GLboolean a
[7]
GLbitfield GLuint64 timeout
[4]
GLsizei GLsizei GLfloat distance
GLenum GLuint GLintptr offset
GLint GLsizei GLsizei GLenum format
GLsizei GLsizei GLchar * source
GLdouble GLdouble GLdouble GLdouble q
static QT_BEGIN_NAMESPACE bool shouldEnableInputMethod(QPlainTextEdit *control)
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
static QT_BEGIN_NAMESPACE QAsn1Element wrap(quint8 type, const QAsn1Element &child)
static QT_BEGIN_NAMESPACE bool shouldEnableInputMethod(QTextEdit *textedit)
QVideoFrameFormat::PixelFormat fmt
view viewport() -> scroll(dx, dy, deviceRect)
app setAttribute(Qt::AA_DontShowIconsInMenus)