Qt 4.8
Classes | Public Types | Public Slots | Signals | Public Functions | Protected Functions | Properties | Friends | List of all members
QTextEdit Class Reference

The QTextEdit class provides a widget that is used to edit and display both plain and rich text. More...

#include <qtextedit.h>

Inheritance diagram for QTextEdit:
QAbstractScrollArea QFrame QWidget QObject QPaintDevice QErrorMessageTextView QMessageBoxDetailsText::TextEdit QTextBrowser

Classes

class  ExtraSelection
 The QTextEdit::ExtraSelection structure provides a way of specifying a character format for a given selection in a document. More...
 

Public Types

enum  AutoFormattingFlag { AutoNone = 0, AutoBulletList = 0x00000001, AutoAll = 0xffffffff }
 
enum  LineWrapMode { NoWrap, WidgetWidth, FixedPixelWidth, FixedColumnWidth }
 
- Public Types inherited from QFrame
enum  Shadow { Plain = 0x0010, Raised = 0x0020, Sunken = 0x0030 }
 This enum type defines the types of shadow that are used to give a 3D effect to frames. More...
 
enum  Shape {
  NoFrame = 0, Box = 0x0001, Panel = 0x0002, WinPanel = 0x0003,
  HLine = 0x0004, VLine = 0x0005, StyledPanel = 0x0006
}
 This enum type defines the shapes of frame available. More...
 
enum  StyleMask { Shadow_Mask = 0x00f0, Shape_Mask = 0x000f }
 This enum defines two constants that can be used to extract the two components of frameStyle(): More...
 
- Public Types inherited from QWidget
enum  RenderFlag { DrawWindowBackground = 0x1, DrawChildren = 0x2, IgnoreMask = 0x4 }
 This enum describes how to render the widget when calling QWidget::render(). More...
 
- Public Types inherited from QPaintDevice
enum  PaintDeviceMetric {
  PdmWidth = 1, PdmHeight, PdmWidthMM, PdmHeightMM,
  PdmNumColors, PdmDepth, PdmDpiX, PdmDpiY,
  PdmPhysicalDpiX, PdmPhysicalDpiY
}
 

Public Slots

void append (const QString &text)
 Appends a new paragraph with text to the end of the text edit. More...
 
void clear ()
 Deletes all the text in the text edit. More...
 
void copy ()
 Copies any selected text to the clipboard. More...
 
void cut ()
 Copies the selected text to the clipboard and deletes it from the text edit. More...
 
void insertHtml (const QString &text)
 Convenience slot that inserts text which is assumed to be of html formatting at the current cursor position. More...
 
void insertPlainText (const QString &text)
 Convenience slot that inserts text at the current cursor position. More...
 
void paste ()
 Pastes the text from the clipboard into the text edit at the current cursor position. More...
 
void redo ()
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
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 empty, or is already visible, or isn't found. More...
 
void selectAll ()
 Selects all text. More...
 
void setAlignment (Qt::Alignment a)
 Sets the alignment of the current paragraph to a. More...
 
void setCurrentFont (const QFont &f)
 Sets the font of the current format to f. More...
 
void setFontFamily (const QString &fontFamily)
 Sets the font family of the current format to fontFamily. More...
 
void setFontItalic (bool b)
 If italic is true, sets the current format to italic; otherwise sets the current format to non-italic. More...
 
void setFontPointSize (qreal s)
 Sets the point size of the current format to s. More...
 
void setFontUnderline (bool b)
 If underline is true, sets the current format to underline; otherwise sets the current format to non-underline. More...
 
void setFontWeight (int w)
 Sets the font weight of the current format to the given weight, where the value used is in the range defined by the QFont::Weight enum. More...
 
void setHtml (const QString &text)
 
void setPlainText (const QString &text)
 Changes the text of the text edit to the string text. More...
 
void setText (const QString &text)
 Sets the text edit's text. More...
 
void setTextBackgroundColor (const QColor &c)
 Sets the text background color of the current format to c. More...
 
void setTextColor (const QColor &c)
 Sets the text color of the current format to c. More...
 
void undo ()
 Undoes the last operation. More...
 
void zoomIn (int range=1)
 Zooms in on the text by making the base font size range points larger and recalculating all font sizes to be the new size. More...
 
void zoomOut (int range=1)
 Zooms out on the text by making the base font size range points smaller and recalculating all font sizes to be the new size. More...
 
- Public Slots inherited from QWidget
bool close ()
 Closes this widget. More...
 
void hide ()
 Hides the widget. More...
 
void lower ()
 Lowers the widget to the bottom of the parent widget's stack. More...
 
void raise ()
 Raises this widget to the top of the parent widget's stack. More...
 
void repaint ()
 Repaints the widget directly by calling paintEvent() immediately, unless updates are disabled or the widget is hidden. More...
 
void setDisabled (bool)
 Disables widget input events if disable is true; otherwise enables input events. More...
 
void setEnabled (bool)
 
void setFocus ()
 Gives the keyboard input focus to this widget (or its focus proxy) if this widget or one of its parents is the active window. More...
 
void setHidden (bool hidden)
 Convenience function, equivalent to setVisible(!hidden). More...
 
QT_MOC_COMPAT void setShown (bool shown)
 Use setVisible(shown) instead. More...
 
void setStyleSheet (const QString &styleSheet)
 
virtual void setVisible (bool visible)
 
void setWindowModified (bool)
 
void setWindowTitle (const QString &)
 
void show ()
 Shows the widget and its child widgets. More...
 
void showFullScreen ()
 Shows the widget in full-screen mode. More...
 
void showMaximized ()
 Shows the widget maximized. More...
 
void showMinimized ()
 Shows the widget minimized, as an icon. More...
 
void showNormal ()
 Restores the widget after it has been maximized or minimized. More...
 
void update ()
 Updates the widget unless updates are disabled or the widget is hidden. More...
 
- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 

Signals

void copyAvailable (bool b)
 This signal is emitted when text is selected or de-selected in the text edit. More...
 
void currentCharFormatChanged (const QTextCharFormat &format)
 This signal is emitted if the current character format has changed, for example caused by a change of the cursor position. More...
 
void cursorPositionChanged ()
 This signal is emitted whenever the position of the cursor changed. More...
 
void redoAvailable (bool b)
 This signal is emitted whenever redo operations become available (available is true) or unavailable (available is false). More...
 
void selectionChanged ()
 This signal is emitted whenever the selection changes. More...
 
void textChanged ()
 This signal is emitted whenever the document's content changes; for example, when text is inserted or deleted, or when formatting is applied. More...
 
void undoAvailable (bool b)
 This signal is emitted whenever undo operations become available (available is true) or unavailable (available is false). More...
 
- Signals inherited from QWidget
void customContextMenuRequested (const QPoint &pos)
 This signal is emitted when the widget's contextMenuPolicy is Qt::CustomContextMenu, and the user has requested a context menu on the widget. More...
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 

Public Functions

bool acceptRichText () const
 
Qt::Alignment alignment () const
 Returns the alignment of the current paragraph. More...
 
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 point. More...
 
AutoFormatting autoFormatting () const
 
bool canPaste () const
 Returns whether text can be pasted from the clipboard into the textedit. More...
 
QMenucreateStandardContextMenu ()
 This function creates the standard context menu which is shown when the user clicks on the text edit with the right mouse button. More...
 
QMenucreateStandardContextMenu (const QPoint &position)
 This function creates the standard context menu which is shown when the user clicks on the text edit with the right mouse button. More...
 
QTextCharFormat currentCharFormat () const
 Returns the char format that is used when inserting new text. More...
 
QFont currentFont () const
 Returns the font of the current format. More...
 
QTextCursor cursorForPosition (const QPoint &pos) const
 returns a QTextCursor at position pos (in viewport coordinates). More...
 
QRect cursorRect (const QTextCursor &cursor) const
 returns a rectangle (in viewport coordinates) that includes the cursor. More...
 
QRect cursorRect () const
 returns a rectangle (in viewport coordinates) that includes the cursor of the text edit. More...
 
int cursorWidth () const
 
QTextDocumentdocument () const
 Returns a pointer to the underlying document. More...
 
QString documentTitle () const
 
void ensureCursorVisible ()
 Ensures that the cursor is visible by scrolling the text edit if necessary. More...
 
QList< ExtraSelectionextraSelections () const
 Returns previously set extra selections. More...
 
bool find (const QString &exp, QTextDocument::FindFlags options=0)
 Finds the next occurrence of the string, exp, using the given options. More...
 
QString fontFamily () const
 Returns the font family of the current format. More...
 
bool fontItalic () const
 Returns true if the font of the current format is italic; otherwise returns false. More...
 
qreal fontPointSize () const
 Returns the point size of the font of the current format. More...
 
bool fontUnderline () const
 Returns true if the font of the current format is underlined; otherwise returns false. More...
 
int fontWeight () const
 Returns the font weight of the current format. More...
 
bool isReadOnly () const
 
bool isUndoRedoEnabled () const
 
int lineWrapColumnOrWidth () const
 
LineWrapMode lineWrapMode () const
 
virtual QVariant loadResource (int type, const QUrl &name)
 Loads the resource specified by the given type and name. More...
 
void mergeCurrentCharFormat (const QTextCharFormat &modifier)
 Merges the properties specified in modifier into the current character format by calling QTextCursor::mergeCharFormat on the editor's cursor. More...
 
void moveCursor (QTextCursor::MoveOperation operation, QTextCursor::MoveMode mode=QTextCursor::MoveAnchor)
 Moves the cursor by performing the given operation. More...
 
bool overwriteMode () const
 
void print (QPrinter *printer) const
 Convenience function to print the text edit's document to the given printer. More...
 
 QTextEdit (QWidget *parent=0)
 Constructs an empty QTextEdit with parent parent. More...
 
 QTextEdit (const QString &text, QWidget *parent=0)
 Constructs a QTextEdit with parent parent. More...
 
void setAcceptRichText (bool accept)
 
void setAutoFormatting (AutoFormatting features)
 
void setCurrentCharFormat (const QTextCharFormat &format)
 Sets the char format that is be used when inserting new text to format by calling QTextCursor::setCharFormat() on the editor's cursor. More...
 
void setCursorWidth (int width)
 
void setDocument (QTextDocument *document)
 Makes document the new document of the text editor. More...
 
void setDocumentTitle (const QString &title)
 
void setExtraSelections (const QList< ExtraSelection > &selections)
 This function allows temporarily marking certain regions in the document with a given color, specified as selections. More...
 
void setLineWrapColumnOrWidth (int w)
 
void setLineWrapMode (LineWrapMode mode)
 
void setOverwriteMode (bool overwrite)
 
void setReadOnly (bool ro)
 
void setTabChangesFocus (bool b)
 
void setTabStopWidth (int width)
 
void setTextCursor (const QTextCursor &cursor)
 Sets the visible cursor. More...
 
void setTextInteractionFlags (Qt::TextInteractionFlags flags)
 
void setUndoRedoEnabled (bool enable)
 
void setWordWrapMode (QTextOption::WrapMode policy)
 
bool tabChangesFocus () const
 
int tabStopWidth () const
 
QColor textBackgroundColor () const
 Returns the text background color of the current format. More...
 
QColor textColor () const
 Returns the text color of the current format. More...
 
QTextCursor textCursor () const
 Returns a copy of the QTextCursor that represents the currently visible cursor. More...
 
Qt::TextInteractionFlags textInteractionFlags () const
 
QString toHtml () const
 
QString toPlainText () const
 Returns the text of the text edit as plain text. More...
 
QTextOption::WrapMode wordWrapMode () const
 the mode QTextEdit will use when wrapping text by words More...
 
virtual ~QTextEdit ()
 Destructor. More...
 
- Public Functions inherited from QAbstractScrollArea
void addScrollBarWidget (QWidget *widget, Qt::Alignment alignment)
 Adds widget as a scroll bar widget in the location specified by alignment. More...
 
QWidgetcornerWidget () const
 Returns the widget in the corner between the two scroll bars. More...
 
QScrollBarhorizontalScrollBar () const
 Returns the horizontal scroll bar. More...
 
Qt::ScrollBarPolicy horizontalScrollBarPolicy () const
 
QSize maximumViewportSize () const
 Returns the size of the viewport as if the scroll bars had no valid scrolling range. More...
 
QSize minimumSizeHint () const
 Reimplemented Function More...
 
 QAbstractScrollArea (QWidget *parent=0)
 Constructs a viewport. More...
 
QWidgetList scrollBarWidgets (Qt::Alignment alignment)
 Returns a list of the currently set scroll bar widgets. More...
 
void setCornerWidget (QWidget *widget)
 Sets the widget in the corner between the two scroll bars to be widget. More...
 
void setHorizontalScrollBar (QScrollBar *scrollbar)
 Replaces the existing horizontal scroll bar with scrollBar, and sets all the former scroll bar's slider properties on the new scroll bar. More...
 
void setHorizontalScrollBarPolicy (Qt::ScrollBarPolicy)
 
void setVerticalScrollBar (QScrollBar *scrollbar)
 Replaces the existing vertical scroll bar with scrollBar, and sets all the former scroll bar's slider properties on the new scroll bar. More...
 
void setVerticalScrollBarPolicy (Qt::ScrollBarPolicy)
 
void setViewport (QWidget *widget)
 Sets the viewport to be the given widget. More...
 
QSize sizeHint () const
 Reimplemented Function More...
 
QScrollBarverticalScrollBar () const
 Returns the vertical scroll bar. More...
 
Qt::ScrollBarPolicy verticalScrollBarPolicy () const
 
QWidgetviewport () const
 Returns the viewport widget. More...
 
 ~QAbstractScrollArea ()
 Destroys the viewport. More...
 
- Public Functions inherited from QFrame
QRect frameRect () const
 
Shadow frameShadow () const
 
Shape frameShape () const
 
int frameStyle () const
 Returns the frame style. More...
 
int frameWidth () const
 
int lineWidth () const
 
int midLineWidth () const
 
 QFrame (QWidget *parent=0, Qt::WindowFlags f=0)
 Constructs a frame widget with frame style NoFrame and a 1-pixel frame width. More...
 
void setFrameRect (const QRect &)
 em>Reimplemented Function More...
 
void setFrameShadow (Shadow)
 
void setFrameShape (Shape)
 
void setFrameStyle (int)
 Sets the frame style to style. More...
 
void setLineWidth (int)
 
void setMidLineWidth (int)
 
QSize sizeHint () const
 em>Reimplemented Function More...
 
 ~QFrame ()
 Destroys the frame. More...
 
- Public Functions inherited from QWidget
bool acceptDrops () const
 
QString accessibleDescription () const
 
QString accessibleName () const
 
QList< QAction * > actions () const
 Returns the (possibly empty) list of this widget's actions. More...
 
void activateWindow ()
 Sets the top-level widget containing this widget to be the active window. More...
 
void addAction (QAction *action)
 Appends the action action to this widget's list of actions. More...
 
void addActions (QList< QAction *> actions)
 Appends the actions actions to this widget's list of actions. More...
 
void adjustSize ()
 Adjusts the size of the widget to fit its contents. More...
 
bool autoFillBackground () const
 
QPalette::ColorRole backgroundRole () const
 Returns the background role of the widget. More...
 
QSize baseSize () const
 
QWidgetchildAt (int x, int y) const
 Returns the visible child widget at the position ({x}, {y}) in the widget's coordinate system. More...
 
QWidgetchildAt (const QPoint &p) const
 Returns the visible child widget at point p in the widget's own coordinate system. More...
 
QRect childrenRect () const
 
QRegion childrenRegion () const
 
void clearFocus ()
 Takes keyboard input focus from the widget. More...
 
void clearMask ()
 Removes any mask set by setMask(). More...
 
QMargins contentsMargins () const
 The contentsMargins function returns the widget's contents margins. More...
 
QRect contentsRect () const
 Returns the area inside the widget's margins. More...
 
Qt::ContextMenuPolicy contextMenuPolicy () const
 
void createWinId ()
 
QCursor cursor () const
 
int devType () const
 
WId effectiveWinId () const
 Returns the effective window system identifier of the widget, i. More...
 
void ensurePolished () const
 Ensures that the widget has been polished by QStyle (i.e., has a proper font and palette). More...
 
Qt::FocusPolicy focusPolicy () const
 
QWidgetfocusProxy () const
 Returns the focus proxy, or 0 if there is no focus proxy. More...
 
QWidgetfocusWidget () const
 Returns the last child of this widget that setFocus had been called on. More...
 
const QFontfont () const
 
QFontInfo fontInfo () const
 Returns the font info for the widget's current font. More...
 
QFontMetrics fontMetrics () const
 Returns the font metrics for the widget's current font. More...
 
QPalette::ColorRole foregroundRole () const
 Returns the foreground role. More...
 
QRect frameGeometry () const
 
QSize frameSize () const
 
const QRectgeometry () const
 
void getContentsMargins (int *left, int *top, int *right, int *bottom) const
 Returns the widget's contents margins for left, top, right, and bottom. More...
 
HDC getDC () const
 Returns the window system handle of the widget, for low-level access. More...
 
void grabGesture (Qt::GestureType type, Qt::GestureFlags flags=Qt::GestureFlags())
 Subscribes the widget to a given gesture with specific flags. More...
 
void grabKeyboard ()
 Grabs the keyboard input. More...
 
void grabMouse ()
 Grabs the mouse input. More...
 
void grabMouse (const QCursor &)
 
int grabShortcut (const QKeySequence &key, Qt::ShortcutContext context=Qt::WindowShortcut)
 Adds a shortcut to Qt's shortcut system that watches for the given key sequence in the given context. More...
 
QGraphicsEffectgraphicsEffect () const
 The graphicsEffect function returns a pointer to the widget's graphics effect. More...
 
QGraphicsProxyWidgetgraphicsProxyWidget () const
 Returns the proxy widget for the corresponding embedded widget in a graphics view; otherwise returns 0. More...
 
bool hasFocus () const
 
bool hasMouseTracking () const
 
int height () const
 
virtual int heightForWidth (int) const
 Returns the preferred height for this widget, given the width w. More...
 
QInputContextinputContext ()
 This function returns the QInputContext for this widget. More...
 
Qt::InputMethodHints inputMethodHints () const
 
void insertAction (QAction *before, QAction *action)
 Inserts the action action to this widget's list of actions, before the action before. More...
 
void insertActions (QAction *before, QList< QAction *> actions)
 Inserts the actions actions to this widget's list of actions, before the action before. More...
 
WId internalWinId () const
 Returns the window system identifier of the widget, or 0 if the widget is not created yet. More...
 
bool isActiveWindow () const
 
bool isAncestorOf (const QWidget *child) const
 Returns true if this widget is a parent, (or grandparent and so on to any level), of the given child, and both widgets are within the same window; otherwise returns false. More...
 
bool isEnabled () const
 
bool isEnabledTo (QWidget *) const
 Returns true if this widget would become enabled if ancestor is enabled; otherwise returns false. More...
 
bool isEnabledToTLW () const
 This function is deprecated. More...
 
bool isFullScreen () const
 
bool isHidden () const
 Returns true if the widget is hidden, otherwise returns false. More...
 
bool isLeftToRight () const
 
bool isMaximized () const
 
bool isMinimized () const
 
bool isModal () const
 
bool isRightToLeft () const
 
bool isTopLevel () const
 Use isWindow() instead. More...
 
bool isVisible () const
 
bool isVisibleTo (QWidget *) const
 Returns true if this widget would become visible if ancestor is shown; otherwise returns false. More...
 
bool isWindow () const
 Returns true if the widget is an independent window, otherwise returns false. More...
 
bool isWindowModified () const
 
QLayoutlayout () const
 Returns the layout manager that is installed on this widget, or 0 if no layout manager is installed. More...
 
Qt::LayoutDirection layoutDirection () const
 
QLocale locale () const
 
Qt::HANDLE macCGHandle () const
 Returns the CoreGraphics handle of the widget. More...
 
Qt::HANDLE macQDHandle () const
 Returns the QuickDraw handle of the widget. More...
 
QPoint mapFrom (QWidget *, const QPoint &) const
 Translates the widget coordinate pos from the coordinate system of parent to this widget's coordinate system. More...
 
QPoint mapFromGlobal (const QPoint &) const
 Translates the global screen coordinate pos to widget coordinates. More...
 
QPoint mapFromParent (const QPoint &) const
 Translates the parent widget coordinate pos to widget coordinates. More...
 
QPoint mapTo (QWidget *, const QPoint &) const
 Translates the widget coordinate pos to the coordinate system of parent. More...
 
QPoint mapToGlobal (const QPoint &) const
 Translates the widget coordinate pos to global screen coordinates. More...
 
QPoint mapToParent (const QPoint &) const
 Translates the widget coordinate pos to a coordinate in the parent widget. More...
 
QRegion mask () const
 Returns the mask currently set on a widget. More...
 
int maximumHeight () const
 
QSize maximumSize () const
 
int maximumWidth () const
 
int minimumHeight () const
 
QSize minimumSize () const
 
int minimumWidth () const
 
void move (int x, int y)
 This corresponds to move(QPoint(x, y)). More...
 
void move (const QPoint &)
 
QWidgetnativeParentWidget () const
 Returns the native parent for this widget, i. More...
 
QWidgetnextInFocusChain () const
 Returns the next widget in this widget's focus chain. More...
 
QRect normalGeometry () const
 
void overrideWindowFlags (Qt::WindowFlags type)
 Sets the window flags for the widget to flags, without telling the window system. More...
 
void overrideWindowState (Qt::WindowStates state)
 
QPaintEnginepaintEngine () const
 Returns the widget's paint engine. More...
 
const QPalettepalette () const
 
QWidgetparentWidget () const
 Returns the parent of this widget, or 0 if it does not have any parent widget. More...
 
QPoint pos () const
 
QWidgetpreviousInFocusChain () const
 The previousInFocusChain function returns the previous widget in this widget's focus chain. More...
 
 QWidget (QWidget *parent=0, Qt::WindowFlags f=0)
 Constructs a widget which is a child of parent, with widget flags set to f. More...
 
QRect rect () const
 
void releaseDC (HDC) const
 Releases the HDC hdc acquired by a previous call to getDC(). More...
 
void releaseKeyboard ()
 Releases the keyboard grab. More...
 
void releaseMouse ()
 Releases the mouse grab. More...
 
void releaseShortcut (int id)
 Removes the shortcut with the given id from Qt's shortcut system. More...
 
void removeAction (QAction *action)
 Removes the action action from this widget's list of actions. More...
 
void render (QPaintDevice *target, const QPoint &targetOffset=QPoint(), const QRegion &sourceRegion=QRegion(), RenderFlags renderFlags=RenderFlags(DrawWindowBackground|DrawChildren))
 Renders the sourceRegion of this widget into the target using renderFlags to determine how to render. More...
 
void render (QPainter *painter, const QPoint &targetOffset=QPoint(), const QRegion &sourceRegion=QRegion(), RenderFlags renderFlags=RenderFlags(DrawWindowBackground|DrawChildren))
 Renders the widget into the painter's QPainter::device(). More...
 
void repaint (int x, int y, int w, int h)
 This version repaints a rectangle (x, y, w, h) inside the widget. More...
 
void repaint (const QRect &)
 This version repaints a rectangle rect inside the widget. More...
 
void repaint (const QRegion &)
 This version repaints a region rgn inside the widget. More...
 
void resize (int w, int h)
 This corresponds to resize(QSize(w, h)). More...
 
void resize (const QSize &)
 
bool restoreGeometry (const QByteArray &geometry)
 Restores the geometry and state top-level widgets stored in the byte array geometry. More...
 
QByteArray saveGeometry () const
 Saves the current geometry and state for top-level widgets. More...
 
void scroll (int dx, int dy)
 Scrolls the widget including its children dx pixels to the right and dy downward. More...
 
void scroll (int dx, int dy, const QRect &)
 This version only scrolls r and does not move the children of the widget. More...
 
void setAcceptDrops (bool on)
 
void setAccessibleDescription (const QString &description)
 
void setAccessibleName (const QString &name)
 
void setAttribute (Qt::WidgetAttribute, bool on=true)
 Sets the attribute attribute on this widget if on is true; otherwise clears the attribute. More...
 
void setAutoFillBackground (bool enabled)
 
void setBackgroundRole (QPalette::ColorRole)
 Sets the background role of the widget to role. More...
 
void setBaseSize (const QSize &)
 
void setBaseSize (int basew, int baseh)
 This corresponds to setBaseSize(QSize(basew, baseh)). More...
 
void setContentsMargins (int left, int top, int right, int bottom)
 Sets the margins around the contents of the widget to have the sizes left, top, right, and bottom. More...
 
void setContentsMargins (const QMargins &margins)
 The setContentsMargins function sets the margins around the widget's contents. More...
 
void setContextMenuPolicy (Qt::ContextMenuPolicy policy)
 
void setCursor (const QCursor &)
 
void setFixedHeight (int h)
 Sets both the minimum and maximum heights of the widget to h without changing the widths. More...
 
void setFixedSize (const QSize &)
 Sets both the minimum and maximum sizes of the widget to s, thereby preventing it from ever growing or shrinking. More...
 
void setFixedSize (int w, int h)
 Sets the width of the widget to w and the height to h. More...
 
void setFixedWidth (int w)
 Sets both the minimum and maximum width of the widget to w without changing the heights. More...
 
void setFocus (Qt::FocusReason reason)
 Gives the keyboard input focus to this widget (or its focus proxy) if this widget or one of its parents is the active window. More...
 
void setFocusPolicy (Qt::FocusPolicy policy)
 
void setFocusProxy (QWidget *)
 Sets the widget's focus proxy to widget w. More...
 
void setFont (const QFont &)
 Use the single-argument overload instead. More...
 
void setForegroundRole (QPalette::ColorRole)
 Sets the foreground role of the widget to role. More...
 
void setGeometry (int x, int y, int w, int h)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.This corresponds to setGeometry(QRect(x, y, w, h)). More...
 
void setGeometry (const QRect &)
 
void setGraphicsEffect (QGraphicsEffect *effect)
 The setGraphicsEffect function is for setting the widget's graphics effect. More...
 
void setInputContext (QInputContext *)
 This function sets the input context context on this widget. More...
 
void setInputMethodHints (Qt::InputMethodHints hints)
 
void setLayout (QLayout *)
 Sets the layout manager for this widget to layout. More...
 
void setLayoutDirection (Qt::LayoutDirection direction)
 
void setLocale (const QLocale &locale)
 
void setMask (const QBitmap &)
 Causes only the pixels of the widget for which bitmap has a corresponding 1 bit to be visible. More...
 
void setMask (const QRegion &)
 Causes only the parts of the widget which overlap region to be visible. More...
 
void setMaximumHeight (int maxh)
 
void setMaximumSize (const QSize &)
 
void setMaximumSize (int maxw, int maxh)
 This function corresponds to setMaximumSize(QSize(maxw, maxh)). More...
 
void setMaximumWidth (int maxw)
 
void setMinimumHeight (int minh)
 
void setMinimumSize (const QSize &)
 
void setMinimumSize (int minw, int minh)
 This function corresponds to setMinimumSize(QSize(minw, minh)). More...
 
void setMinimumWidth (int minw)
 
void setMouseTracking (bool enable)
 
void setPalette (const QPalette &)
 Use the single-argument overload instead. More...
 
void setParent (QWidget *parent)
 Sets the parent of the widget to parent, and resets the window flags. More...
 
void setParent (QWidget *parent, Qt::WindowFlags f)
 This function also takes widget flags, f as an argument. More...
 
void setShortcutAutoRepeat (int id, bool enable=true)
 If enable is true, auto repeat of the shortcut with the given id is enabled; otherwise it is disabled. More...
 
void setShortcutEnabled (int id, bool enable=true)
 If enable is true, the shortcut with the given id is enabled; otherwise the shortcut is disabled. More...
 
void setSizeIncrement (const QSize &)
 
void setSizeIncrement (int w, int h)
 Sets the x (width) size increment to w and the y (height) size increment to h. More...
 
void setSizePolicy (QSizePolicy)
 
void setSizePolicy (QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical)
 Sets the size policy of the widget to horizontal and vertical, with standard stretch and no height-for-width. More...
 
void setStatusTip (const QString &)
 
void setStyle (QStyle *)
 Sets the widget's GUI style to style. More...
 
void setToolTip (const QString &)
 
void setUpdatesEnabled (bool enable)
 
void setupUi (QWidget *widget)
 Sets up the user interface for the specified widget. More...
 
void setWhatsThis (const QString &)
 
void setWindowFilePath (const QString &filePath)
 
void setWindowFlags (Qt::WindowFlags type)
 
void setWindowIcon (const QIcon &icon)
 
void setWindowIconText (const QString &)
 
void setWindowModality (Qt::WindowModality windowModality)
 
void setWindowOpacity (qreal level)
 
void setWindowRole (const QString &)
 Sets the window's role to role. More...
 
void setWindowState (Qt::WindowStates state)
 Sets the window state to windowState. More...
 
void setWindowSurface (QWindowSurface *surface)
 Sets the window surface to be the surface specified. More...
 
QSize size () const
 
QSize sizeIncrement () const
 
QSizePolicy sizePolicy () const
 
void stackUnder (QWidget *)
 Places the widget under w in the parent widget's stack. More...
 
QString statusTip () const
 
QStylestyle () const
 
QString styleSheet () const
 
bool testAttribute (Qt::WidgetAttribute) const
 Returns true if attribute attribute is set on this widget; otherwise returns false. More...
 
QString toolTip () const
 
QWidgettopLevelWidget () const
 
bool underMouse () const
 Returns true if the widget is under the mouse cursor; otherwise returns false. More...
 
void ungrabGesture (Qt::GestureType type)
 Unsubscribes the widget from a given gesture type. More...
 
void unsetCursor ()
 
void unsetLayoutDirection ()
 
void unsetLocale ()
 
void update (int x, int y, int w, int h)
 This version updates a rectangle (x, y, w, h) inside the widget. More...
 
void update (const QRect &)
 This version updates a rectangle rect inside the widget. More...
 
void update (const QRegion &)
 This version repaints a region rgn inside the widget. More...
 
void updateGeometry ()
 Notifies the layout system that this widget has changed and may need to change geometry. More...
 
bool updatesEnabled () const
 
QRegion visibleRegion () const
 Returns the unobscured region where paint events can occur. More...
 
QString whatsThis () const
 
int width () const
 
QWidgetwindow () const
 Returns the window for this widget, i.e. More...
 
QString windowFilePath () const
 
Qt::WindowFlags windowFlags () const
 Window flags are a combination of a type (e. More...
 
QIcon windowIcon () const
 
QString windowIconText () const
 
Qt::WindowModality windowModality () const
 
qreal windowOpacity () const
 
QString windowRole () const
 Returns the window's role, or an empty string. More...
 
Qt::WindowStates windowState () const
 Returns the current window state. More...
 
QWindowSurfacewindowSurface () const
 Returns the QWindowSurface this widget will be drawn into. More...
 
QString windowTitle () const
 
Qt::WindowType windowType () const
 Returns the window type of this widget. More...
 
WId winId () const
 Returns the window system identifier of the widget. More...
 
int x () const
 
const QX11Infox11Info () const
 Returns information about the configuration of the X display used to display the widget. More...
 
Qt::HANDLE x11PictureHandle () const
 Returns the X11 Picture handle of the widget for XRender support. More...
 
int y () const
 
 ~QWidget ()
 Destroys the widget. More...
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 
- Public Functions inherited from QPaintDevice
int colorCount () const
 
int depth () const
 
int height () const
 
int heightMM () const
 
int logicalDpiX () const
 
int logicalDpiY () const
 
QT_DEPRECATED int numColors () const
 
bool paintingActive () const
 
int physicalDpiX () const
 
int physicalDpiY () const
 
int width () const
 
int widthMM () const
 
virtual ~QPaintDevice ()
 

Protected Functions

virtual bool canInsertFromMimeData (const QMimeData *source) const
 This function returns true if the contents of the MIME data object, specified by source, can be decoded and inserted into the document. More...
 
virtual void changeEvent (QEvent *e)
 Reimplemented Function More...
 
virtual void contextMenuEvent (QContextMenuEvent *e)
 Shows the standard context menu created with createStandardContextMenu(). More...
 
virtual QMimeDatacreateMimeDataFromSelection () const
 This function returns a new MIME data object to represent the contents of the text edit's current selection. More...
 
virtual void dragEnterEvent (QDragEnterEvent *e)
 Reimplemented Function More...
 
virtual void dragLeaveEvent (QDragLeaveEvent *e)
 Reimplemented Function More...
 
virtual void dragMoveEvent (QDragMoveEvent *e)
 Reimplemented Function More...
 
virtual void dropEvent (QDropEvent *e)
 Reimplemented Function More...
 
virtual bool event (QEvent *e)
 
virtual void focusInEvent (QFocusEvent *e)
 Reimplemented Function More...
 
virtual bool focusNextPrevChild (bool next)
 Reimplemented Function More...
 
virtual void focusOutEvent (QFocusEvent *e)
 Reimplemented Function More...
 
virtual void inputMethodEvent (QInputMethodEvent *)
 Reimplemented Function More...
 
QVariant inputMethodQuery (Qt::InputMethodQuery property) const
 This method is only relevant for input widgets. More...
 
virtual void insertFromMimeData (const QMimeData *source)
 This function inserts the contents of the MIME data object, specified by source, into the text edit at the current cursor position. More...
 
virtual void keyPressEvent (QKeyEvent *e)
 Reimplemented Function More...
 
virtual void keyReleaseEvent (QKeyEvent *e)
 Reimplemented Function More...
 
virtual void mouseDoubleClickEvent (QMouseEvent *e)
 Reimplemented Function More...
 
virtual void mouseMoveEvent (QMouseEvent *e)
 Reimplemented Function More...
 
virtual void mousePressEvent (QMouseEvent *e)
 Reimplemented Function More...
 
virtual void mouseReleaseEvent (QMouseEvent *e)
 Reimplemented Function More...
 
virtual void paintEvent (QPaintEvent *e)
 This event handler can be reimplemented in a subclass to receive paint events passed in event. More...
 
 QTextEdit (QTextEditPrivate &dd, QWidget *parent)
 
virtual void resizeEvent (QResizeEvent *e)
 Reimplemented Function More...
 
virtual void scrollContentsBy (int dx, int dy)
 em>Reimplemented Function More...
 
virtual void showEvent (QShowEvent *)
 Reimplemented Function More...
 
virtual void timerEvent (QTimerEvent *e)
 
virtual void wheelEvent (QWheelEvent *e)
 Reimplemented Function More...
 
- Protected Functions inherited from QAbstractScrollArea
 QAbstractScrollArea (QAbstractScrollAreaPrivate &dd, QWidget *parent=0)
 Creates a new QAbstractScrollAreaPrivate, dd with the given parent. More...
 
void setViewportMargins (int left, int top, int right, int bottom)
 Sets the margins around the scrolling area to left, top, right and bottom. More...
 
void setViewportMargins (const QMargins &margins)
 Sets margins around the scrolling area. More...
 
virtual bool viewportEvent (QEvent *)
 The main event handler for the scrolling area (the viewport() widget). More...
 
- Protected Functions inherited from QFrame
void drawFrame (QPainter *)
 em>Reimplemented Function More...
 
 QFrame (QFramePrivate &dd, QWidget *parent=0, Qt::WindowFlags f=0)
 
- Protected Functions inherited from QWidget
virtual void actionEvent (QActionEvent *)
 This event handler is called with the given event whenever the widget's actions are changed. More...
 
virtual void closeEvent (QCloseEvent *)
 This event handler is called with the given event when Qt receives a window close request for a top-level widget from the window system. More...
 
void create (WId=0, bool initializeWindow=true, bool destroyOldWindow=true)
 Creates a new widget window if window is 0, otherwise sets the widget's window to window. More...
 
void destroy (bool destroyWindow=true, bool destroySubWindows=true)
 Frees up window system resources. More...
 
virtual void enabledChange (bool)
 
virtual void enterEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive widget enter events which are passed in the event parameter. More...
 
bool focusNextChild ()
 Finds a new widget to give the keyboard focus to, as appropriate for Tab, and returns true if it can find a new widget, or false if it can't. More...
 
bool focusPreviousChild ()
 Finds a new widget to give the keyboard focus to, as appropriate for Shift+Tab, and returns true if it can find a new widget, or false if it can't. More...
 
virtual void fontChange (const QFont &)
 
virtual void hideEvent (QHideEvent *)
 This event handler can be reimplemented in a subclass to receive widget hide events. More...
 
virtual void languageChange ()
 
virtual void leaveEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive widget leave events which are passed in the event parameter. More...
 
virtual bool macEvent (EventHandlerCallRef, EventRef)
 This special event handler can be reimplemented in a subclass to receive native Macintosh events. More...
 
int metric (PaintDeviceMetric) const
 Internal implementation of the virtual QPaintDevice::metric() function. More...
 
virtual void moveEvent (QMoveEvent *)
 This event handler can be reimplemented in a subclass to receive widget move events which are passed in the event parameter. More...
 
virtual void paletteChange (const QPalette &)
 
 QWidget (QWidgetPrivate &d, QWidget *parent, Qt::WindowFlags f)
 
virtual bool qwsEvent (QWSEvent *)
 This special event handler can be reimplemented in a subclass to receive native Qt for Embedded Linux events which are passed in the event parameter. More...
 
void resetInputContext ()
 This function can be called on the widget that currently has focus to reset the input method operating on it. More...
 
virtual void styleChange (QStyle &)
 
virtual void tabletEvent (QTabletEvent *)
 This event handler, for event event, can be reimplemented in a subclass to receive tablet events for the widget. More...
 
virtual void windowActivationChange (bool)
 
virtual bool winEvent (MSG *message, long *result)
 This special event handler can be reimplemented in a subclass to receive native Windows events which are passed in the message parameter. More...
 
virtual bool x11Event (XEvent *)
 This special event handler can be reimplemented in a subclass to receive native X11 events passed in the event parameter. More...
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
- Protected Functions inherited from QPaintDevice
 QPaintDevice ()
 

Properties

bool acceptRichText
 whether the text edit accepts rich text insertions by the user More...
 
AutoFormatting autoFormatting
 the enabled set of auto formatting features More...
 
int cursorWidth
 This property specifies the width of the cursor in pixels. More...
 
QString documentTitle
 the title of the document parsed from the text. More...
 
QString html
 This property provides an HTML interface to the text of the text edit. More...
 
int lineWrapColumnOrWidth
 the position (in pixels or columns depending on the wrap mode) where text will be wrapped More...
 
LineWrapMode lineWrapMode
 the line wrap mode More...
 
bool overwriteMode
 whether text entered by the user will overwrite existing text More...
 
QString plainText
 This property gets and sets the text editor's contents as plain text. More...
 
bool readOnly
 whether the text edit is read-only More...
 
bool tabChangesFocus
 whether Tab changes focus or is accepted as input More...
 
int tabStopWidth
 the tab stop width in pixels More...
 
Qt::TextInteractionFlags textInteractionFlags
 Specifies how the widget should interact with user input. More...
 
bool undoRedoEnabled
 whether undo and redo are enabled More...
 

Friends

class QTextControl
 
class QTextDocument
 
class QTextEditControl
 

Additional Inherited Members

- Static Public Functions inherited from QWidget
static QWidgetfind (WId)
 Returns a pointer to the widget with window identifer/handle id. More...
 
static QWidgetkeyboardGrabber ()
 Returns the widget that is currently grabbing the keyboard input. More...
 
static QWidgetmouseGrabber ()
 Returns the widget that is currently grabbing the mouse input. More...
 
static void setTabOrder (QWidget *, QWidget *)
 Puts the second widget after the first widget in the focus order. More...
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
- Static Public Functions inherited from QPaintDevice
static QWSDisplayqwsDisplay ()
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Slots inherited from QAbstractScrollArea
void setupViewport (QWidget *viewport)
 This slot is called by QAbstractScrollArea after setViewport(viewport) has been called. More...
 
- Protected Slots inherited from QWidget
void updateMicroFocus ()
 Updates the widget's micro focus. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Protected Variables inherited from QPaintDevice
ushort painters
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

The QTextEdit class provides a widget that is used to edit and display both plain and rich text.

Introduction and Concepts

QTextEdit is an advanced WYSIWYG viewer/editor supporting rich text formatting using HTML-style tags. It is optimized to handle large documents and to respond quickly to user input.

QTextEdit works on paragraphs and characters. A paragraph is a formatted string which is word-wrapped to fit into the width of the widget. By default when reading plain text, one newline signifies a paragraph. A document consists of zero or more paragraphs. The words in the paragraph are aligned in accordance with the paragraph's alignment. Paragraphs are separated by hard line breaks. Each character within a paragraph has its own attributes, for example, font and color.

QTextEdit can display images, lists and tables. If the text is too large to view within the text edit's viewport, scroll bars will appear. The text edit can load both plain text and HTML files (a subset of HTML 3.2 and 4).

If you just need to display a small piece of rich text use QLabel.

The rich text support in Qt is designed to provide a fast, portable and efficient way to add reasonable online help facilities to applications, and to provide a basis for rich text editors. If you find the HTML support insufficient for your needs you may consider the use of QtWebKit, which provides a full-featured web browser widget.

The shape of the mouse cursor on a QTextEdit is Qt::IBeamCursor by default. It can be changed through the viewport()'s cursor property.

Using QTextEdit as a Display Widget

QTextEdit can display a large HTML subset, including tables and images.

The text is set or replaced using setHtml() which deletes any existing text and replaces it with the text passed in the setHtml() call. If you call setHtml() with legacy HTML, and then call toHtml(), the text that is returned may have different markup, but will render the same. The entire text can be deleted with clear().

Text itself can be inserted using the QTextCursor class or using the convenience functions insertHtml(), insertPlainText(), append() or paste(). QTextCursor is also able to insert complex objects like tables or lists into the document, and it deals with creating selections and applying changes to selected text.

By default the text edit wraps words at whitespace to fit within the text edit widget. The setLineWrapMode() function is used to specify the kind of line wrap you want, or NoWrap if you don't want any wrapping. Call setLineWrapMode() to set a fixed pixel width FixedPixelWidth , or character column (e.g. 80 column) FixedColumnWidth with the pixels or columns specified with setLineWrapColumnOrWidth(). If you use word wrap to the widget's width WidgetWidth , you can specify whether to break on whitespace or anywhere with setWordWrapMode().

The find() function can be used to find and select a given string within the text.

If you want to limit the total number of paragraphs in a QTextEdit, as for example it is often useful in a log viewer, then you can use QTextDocument's maximumBlockCount property for that.

Read-only Key Bindings

When QTextEdit is used read-only the key bindings are limited to navigation, and text may only be selected with the mouse:

Keypresses Action
Up Moves one line up.
Down Moves one line down.
Left Moves one character to the left.
Right Moves one character to the right.
PageUp Moves one (viewport) page up.
PageDown Moves one (viewport) page down.
Home Moves to the beginning of the text.
End Moves to the end of the text.
Alt+Wheel Scrolls the page horizontally (the Wheel is the mouse wheel).
Ctrl+Wheel Zooms the text.
Ctrl+A Selects all text.

The text edit may be able to provide some meta-information. For example, the documentTitle() function will return the text from within HTML <title> tags.

Using QTextEdit as an Editor

All the information about using QTextEdit as a display widget also applies here.

The current char format's attributes are set with setFontItalic(), setFontWeight(), setFontUnderline(), setFontFamily(), setFontPointSize(), setTextColor() and setCurrentFont(). The current paragraph's alignment is set with setAlignment().

Selection of text is handled by the QTextCursor class, which provides functionality for creating selections, retrieving the text contents or deleting selections. You can retrieve the object that corresponds with the user-visible cursor using the textCursor() method. If you want to set a selection in QTextEdit just create one on a QTextCursor object and then make that cursor the visible cursor using setTextCursor(). The selection can be copied to the clipboard with copy(), or cut to the clipboard with cut(). The entire text can be selected using selectAll().

When the cursor is moved and the underlying formatting attributes change, the currentCharFormatChanged() signal is emitted to reflect the new attributes at the new cursor position.

QTextEdit holds a QTextDocument object which can be retrieved using the document() method. You can also set your own document object using setDocument(). QTextDocument emits a textChanged() signal if the text changes and it also provides a isModified() function which will return true if the text has been modified since it was either loaded or since the last call to setModified with false as argument. In addition it provides methods for undo and redo.

Drag and Drop

QTextEdit also supports custom drag and drop behavior. By default, QTextEdit will insert plain text, HTML and rich text when the user drops data of these MIME types onto a document. Reimplement canInsertFromMimeData() and insertFromMimeData() to add support for additional MIME types.

For example, to allow the user to drag and drop an image onto a QTextEdit, you could the implement these functions in the following way:

bool TextEdit::canInsertFromMimeData( const QMimeData *source ) const
{
if (source->hasImage())
return true;
else
}

We add support for image MIME types by returning true. For all other MIME types, we use the default implementation.

void TextEdit::insertFromMimeData( const QMimeData *source )
{
if (source->hasImage())
{
QImage image = qvariant_cast<QImage>(source->imageData());
document->addResource(QTextDocument::ImageResource, QUrl("image"), image);
cursor.insertImage("image");
}
}

We unpack the image from the QVariant held by the MIME source and insert it into the document as a resource.

Editing Key Bindings

The list of key bindings which are implemented for editing:

Keypresses Action
Backspace Deletes the character to the left of the cursor.
Delete Deletes the character to the right of the cursor.
Ctrl+C Copy the selected text to the clipboard.
Ctrl+Insert Copy the selected text to the clipboard.
Ctrl+K Deletes to the end of the line.
Ctrl+V Pastes the clipboard text into text edit.
Shift+Insert Pastes the clipboard text into text edit.
Ctrl+X Deletes the selected text and copies it to the clipboard.
Shift+Delete Deletes the selected text and copies it to the clipboard.
Ctrl+Z Undoes the last operation.
Ctrl+Y Redoes the last operation.
Left Moves the cursor one character to the left.
Ctrl+Left Moves the cursor one word to the left.
Right Moves the cursor one character to the right.
Ctrl+Right Moves the cursor one word to the right.
Up Moves the cursor one line up.
Down Moves the cursor one line down.
PageUp Moves the cursor one page up.
PageDown Moves the cursor one page down.
Home Moves the cursor to the beginning of the line.
Ctrl+Home Moves the cursor to the beginning of the text.
End Moves the cursor to the end of the line.
Ctrl+End Moves the cursor to the end of the text.
Alt+Wheel Scrolls the page horizontally (the Wheel is the mouse wheel).

To select (mark) text hold down the Shift key whilst pressing one of the movement keystrokes, for example, Shift+Right will select the character to the right, and Shift+Ctrl+Right will select the word to the right, etc.

See also
QTextDocument, QTextCursor, {Application Example}, {Syntax Highlighter Example}, {Rich Text Processing}

Definition at line 70 of file qtextedit.h.

Enumerations

◆ AutoFormattingFlag

  • AutoNone Don't do any automatic formatting.
  • AutoBulletList Automatically create bullet lists (e.g. when the user enters an asterisk ('*') in the left most column, or presses Enter in an existing list item.
  • AutoAll Apply all automatic formatting. Currently only automatic bullet lists are supported.
Enumerator
AutoNone 
AutoBulletList 
AutoAll 

Definition at line 101 of file qtextedit.h.

101  {
102  AutoNone = 0,
103  AutoBulletList = 0x00000001,
104  AutoAll = 0xffffffff
105  };

◆ LineWrapMode

  • NoWrap
  • WidgetWidth
  • FixedPixelWidth
  • FixedColumnWidth
Enumerator
NoWrap 
WidgetWidth 
FixedPixelWidth 
FixedColumnWidth 

Definition at line 94 of file qtextedit.h.

Constructors and Destructors

◆ QTextEdit() [1/3]

QTextEdit::QTextEdit ( QWidget parent = 0)
explicit

Constructs an empty QTextEdit with parent parent.

Definition at line 608 of file qtextedit.cpp.

Referenced by QTextBrowser::QTextBrowser(), and QTextEdit().

609  : QAbstractScrollArea(*new QTextEditPrivate, parent)
610 {
611  Q_D(QTextEdit);
612  d->init();
613 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
QAbstractScrollArea(QWidget *parent=0)
Constructs a viewport.
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ QTextEdit() [2/3]

QTextEdit::QTextEdit ( const QString text,
QWidget parent = 0 
)
explicit

Constructs a QTextEdit with parent parent.

The text edit will display the text text. The text is interpreted as html.

Definition at line 629 of file qtextedit.cpp.

630  : QAbstractScrollArea(*new QTextEditPrivate, parent)
631 {
632  Q_D(QTextEdit);
633  d->init(text);
634 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
QAbstractScrollArea(QWidget *parent=0)
Constructs a viewport.
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ ~QTextEdit()

QTextEdit::~QTextEdit ( )
virtual

Destructor.

Definition at line 654 of file qtextedit.cpp.

655 {
656 }

◆ QTextEdit() [3/3]

QTextEdit::QTextEdit ( QTextEditPrivate dd,
QWidget parent 
)
protected
Warning
This function is not part of the public interface.

Definition at line 618 of file qtextedit.cpp.

619  : QAbstractScrollArea(dd, parent)
620 {
621  Q_D(QTextEdit);
622  d->init();
623 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
QAbstractScrollArea(QWidget *parent=0)
Constructs a viewport.
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

Functions

◆ acceptRichText()

bool QTextEdit::acceptRichText ( ) const

Referenced by setCursorWidth().

◆ alignment()

Qt::Alignment QTextEdit::alignment ( ) const

Returns the alignment of the current paragraph.

See also
setAlignment()

Definition at line 774 of file qtextedit.cpp.

775 {
776  Q_D(const QTextEdit);
777  return d->control->textCursor().blockFormat().alignment();
778 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ anchorAt()

QString QTextEdit::anchorAt ( const QPoint pos) const

Returns the reference of the anchor at position pos, or an empty string if no anchor exists at that point.

Definition at line 1901 of file qtextedit.cpp.

1902 {
1903  Q_D(const QTextEdit);
1904  return d->control->anchorAt(d->mapToContents(pos));
1905 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ append

void QTextEdit::append ( const QString text)
slot

Appends a new paragraph with text to the end of the text edit.

Note
The new paragraph appended will have the same character format and block format as the current paragraph, determined by the position of the cursor.
See also
currentCharFormat(), QTextCursor::blockFormat()

Definition at line 2729 of file qtextedit.cpp.

2730 {
2731  Q_D(QTextEdit);
2732  const bool atBottom = isReadOnly() ? d->verticalOffset() >= d->vbar->maximum() :
2733  d->control->textCursor().atEnd();
2734  d->control->append(text);
2735  if (atBottom)
2736  d->vbar->setValue(d->vbar->maximum());
2737 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
bool isReadOnly() const
Definition: qtextedit.cpp:2127
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ autoFormatting()

AutoFormatting QTextEdit::autoFormatting ( ) const

Referenced by currentCharFormat().

◆ canInsertFromMimeData()

bool QTextEdit::canInsertFromMimeData ( const QMimeData source) const
protectedvirtual

This function returns true if the contents of the MIME data object, specified by source, can be decoded and inserted into the document.

It is called for example when during a drag operation the mouse enters this widget and it is necessary to determine whether it is possible to accept the drag and drop operation.

Reimplement this function to enable drag and drop support for additional MIME types.

Definition at line 2093 of file qtextedit.cpp.

Referenced by QTextEditControl::canInsertFromMimeData().

2094 {
2095  Q_D(const QTextEdit);
2096  return d->control->QTextControl::canInsertFromMimeData(source);
2097 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ canPaste()

bool QTextEdit::canPaste ( ) const

Returns whether text can be pasted from the clipboard into the textedit.

Since
4.2

Definition at line 2362 of file qtextedit.cpp.

2363 {
2364  Q_D(const QTextEdit);
2365  return d->control->canPaste();
2366 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ changeEvent()

void QTextEdit::changeEvent ( QEvent e)
protectedvirtual

Reimplemented Function

Reimplemented from QFrame.

Definition at line 1782 of file qtextedit.cpp.

1783 {
1784  Q_D(QTextEdit);
1787  || e->type() == QEvent::FontChange) {
1788  d->control->document()->setDefaultFont(font());
1789  } else if(e->type() == QEvent::ActivationChange) {
1790  if (!isActiveWindow())
1791  d->autoScrollTimer.stop();
1792  } else if (e->type() == QEvent::EnabledChange) {
1793  e->setAccepted(isEnabled());
1794  d->control->setPalette(palette());
1795  d->sendControlEvent(e);
1796  } else if (e->type() == QEvent::PaletteChange) {
1797  d->control->setPalette(palette());
1798  } else if (e->type() == QEvent::LayoutDirectionChange) {
1799  d->sendControlEvent(e);
1800  }
1801 }
double d
Definition: qnumeric_p.h:62
void setAccepted(bool accepted)
Definition: qcoreevent.h:306
bool isActiveWindow() const
#define Q_D(Class)
Definition: qglobal.h:2482
void changeEvent(QEvent *)
This event handler can be reimplemented to handle state changes.
Definition: qframe.cpp:574
const QPalette & palette() const
bool isEnabled() const
Definition: qwidget.h:948
const QFont & font() const
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ clear

void QTextEdit::clear ( )
slot

Deletes all the text in the text edit.

Note that the undo/redo history is cleared by this function.

See also
cut() setPlainText() setHtml()

Definition at line 1050 of file qtextedit.cpp.

Referenced by timerEvent().

1051 {
1052  Q_D(QTextEdit);
1053  // clears and sets empty content
1054  d->control->clear();
1055 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ contextMenuEvent()

void QTextEdit::contextMenuEvent ( QContextMenuEvent event)
protectedvirtual

Shows the standard context menu created with createStandardContextMenu().

If you do not want the text edit to have a context menu, you can set its contextMenuPolicy to Qt::NoContextMenu. If you want to customize the context menu, reimplement this function. If you want to extend the standard context menu, reimplement this function, call createStandardContextMenu() and extend the menu returned.

Information about the event is passed in the event object.

void MyTextEdit::contextMenuEvent(QContextMenuEvent *event)
{
menu->addAction(tr("My Menu Item"));
//...
menu->exec(event->globalPos());
delete menu;
}

Reimplemented from QAbstractScrollArea.

Reimplemented in QMessageBoxDetailsText::TextEdit.

Definition at line 1651 of file qtextedit.cpp.

1652 {
1653  Q_D(QTextEdit);
1654  d->sendControlEvent(e);
1655 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ copy

void QTextEdit::copy ( )
slot

Copies any selected text to the clipboard.

See also
copyAvailable()

Definition at line 1016 of file qtextedit.cpp.

1017 {
1018  Q_D(QTextEdit);
1019  d->control->copy();
1020 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ copyAvailable

void QTextEdit::copyAvailable ( bool  yes)
signal

This signal is emitted when text is selected or de-selected in the text edit.

When text is selected this signal will be emitted with yes set to true. If no text has been selected or if the selected text is de-selected this signal is emitted with yes set to false.

If yes is true then copy() can be used to copy the selection to the clipboard. If yes is false then copy() does nothing.

See also
selectionChanged()

◆ createMimeDataFromSelection()

QMimeData * QTextEdit::createMimeDataFromSelection ( ) const
protectedvirtual

This function returns a new MIME data object to represent the contents of the text edit's current selection.

It is called when the selection needs to be encapsulated into a new QMimeData object; for example, when a drag and drop operation is started, or when data is copyied to the clipboard.

If you reimplement this function, note that the ownership of the returned QMimeData object is passed to the caller. The selection can be retrieved by using the textCursor() function.

Definition at line 2078 of file qtextedit.cpp.

Referenced by QTextEditControl::createMimeDataFromSelection().

2079 {
2080  Q_D(const QTextEdit);
2081  return d->control->QTextControl::createMimeDataFromSelection();
2082 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ createStandardContextMenu() [1/2]

QMenu * QTextEdit::createStandardContextMenu ( )

This function creates the standard context menu which is shown when the user clicks on the text edit with the right mouse button.

It is called from the default contextMenuEvent() handler. The popup menu's ownership is transferred to the caller.

We recommend that you use the createStandardContextMenu(QPoint) version instead which will enable the actions that are sensitive to where the user clicked.

Definition at line 1834 of file qtextedit.cpp.

Referenced by QMessageBoxDetailsText::TextEdit::contextMenuEvent().

1835 {
1836  Q_D(QTextEdit);
1837  return d->control->createStandardContextMenu(QPointF(), this);
1838 }
double d
Definition: qnumeric_p.h:62
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ createStandardContextMenu() [2/2]

QMenu * QTextEdit::createStandardContextMenu ( const QPoint position)

This function creates the standard context menu which is shown when the user clicks on the text edit with the right mouse button.

Since
4.4 It is called from the default contextMenuEvent() handler and it takes the position of where the mouse click was. This can enable actions that are sensitive to the position where the user clicked. The popup menu's ownership is transferred to the caller.

Definition at line 1853 of file qtextedit.cpp.

1854 {
1855  Q_D(QTextEdit);
1856  return d->control->createStandardContextMenu(position, this);
1857 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ currentCharFormat()

QTextCharFormat QTextEdit::currentCharFormat ( ) const

Returns the char format that is used when inserting new text.

Definition at line 2204 of file qtextedit.cpp.

2205 {
2206  Q_D(const QTextEdit);
2207  return d->control->currentCharFormat();
2208 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ currentCharFormatChanged

void QTextEdit::currentCharFormatChanged ( const QTextCharFormat f)
signal

This signal is emitted if the current character format has changed, for example caused by a change of the cursor position.

The new format is f.

See also
setCurrentCharFormat()

◆ currentFont()

QFont QTextEdit::currentFont ( ) const

Returns the font of the current format.

See also
setCurrentFont() setFontFamily() setFontPointSize()

Definition at line 747 of file qtextedit.cpp.

748 {
749  Q_D(const QTextEdit);
750  return d->control->textCursor().charFormat().font();
751 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ cursorForPosition()

QTextCursor QTextEdit::cursorForPosition ( const QPoint pos) const

returns a QTextCursor at position pos (in viewport coordinates).

Definition at line 1863 of file qtextedit.cpp.

Referenced by QAccessibleTextEdit::childAt().

1864 {
1865  Q_D(const QTextEdit);
1866  return d->control->cursorForPosition(d->mapToContents(pos));
1867 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ cursorPositionChanged

void QTextEdit::cursorPositionChanged ( )
signal

This signal is emitted whenever the position of the cursor changed.

◆ cursorRect() [1/2]

QRect QTextEdit::cursorRect ( const QTextCursor cursor) const

returns a rectangle (in viewport coordinates) that includes the cursor.

Definition at line 1873 of file qtextedit.cpp.

Referenced by QAccessibleTextEdit::scrollToSubstring().

1874 {
1875  Q_D(const QTextEdit);
1876  if (cursor.isNull())
1877  return QRect();
1878 
1879  QRect r = d->control->cursorRect(cursor).toRect();
1880  r.translate(-d->horizontalOffset(),-d->verticalOffset());
1881  return r;
1882 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
bool isNull() const
Returns true if the cursor is null; otherwise returns false.
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
void translate(int dx, int dy)
Moves the rectangle dx along the x axis and dy along the y axis, relative to the current position...
Definition: qrect.h:312
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ cursorRect() [2/2]

QRect QTextEdit::cursorRect ( ) const

returns a rectangle (in viewport coordinates) that includes the cursor of the text edit.

Definition at line 1888 of file qtextedit.cpp.

Referenced by event().

1889 {
1890  Q_D(const QTextEdit);
1891  QRect r = d->control->cursorRect().toRect();
1892  r.translate(-d->horizontalOffset(),-d->verticalOffset());
1893  return r;
1894 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
void translate(int dx, int dy)
Moves the rectangle dx along the x axis and dy along the y axis, relative to the current position...
Definition: qrect.h:312
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ cursorWidth()

int QTextEdit::cursorWidth ( ) const

Referenced by setTabStopWidth().

◆ cut

void QTextEdit::cut ( )
slot

Copies the selected text to the clipboard and deletes it from the text edit.

If there is no selected text nothing happens.

See also
copy() paste()

Definition at line 1004 of file qtextedit.cpp.

1005 {
1006  Q_D(QTextEdit);
1007  d->control->cut();
1008 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ document()

QTextDocument * QTextEdit::document ( ) const

Returns a pointer to the underlying document.

See also
setDocument()

Definition at line 804 of file qtextedit.cpp.

Referenced by QAccessibleTextEdit::childCount(), keyPressEvent(), QSyntaxHighlighter::QSyntaxHighlighter(), QAccessibleTextEdit::rect(), QAccessibleTextEdit::scrollToSubstring(), and QAccessibleTextEdit::textDocument().

805 {
806  Q_D(const QTextEdit);
807  return d->control->document();
808 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ documentTitle()

QString QTextEdit::documentTitle ( ) const
inline

Definition at line 170 of file qtextedit.h.

Referenced by QTextBrowser::setSource().

QTextDocument * document() const
Returns a pointer to the underlying document.
Definition: qtextedit.cpp:804
QString metaInformation(MetaInformation info) const
Returns meta information about the document of the type specified by info.

◆ dragEnterEvent()

void QTextEdit::dragEnterEvent ( QDragEnterEvent e)
protectedvirtual

Reimplemented Function

Reimplemented from QAbstractScrollArea.

Definition at line 1661 of file qtextedit.cpp.

1662 {
1663  Q_D(QTextEdit);
1664  d->inDrag = true;
1665  d->sendControlEvent(e);
1666 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ dragLeaveEvent()

void QTextEdit::dragLeaveEvent ( QDragLeaveEvent e)
protectedvirtual

Reimplemented Function

Reimplemented from QAbstractScrollArea.

Definition at line 1670 of file qtextedit.cpp.

1671 {
1672  Q_D(QTextEdit);
1673  d->inDrag = false;
1674  d->autoScrollTimer.stop();
1675  d->sendControlEvent(e);
1676 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ dragMoveEvent()

void QTextEdit::dragMoveEvent ( QDragMoveEvent e)
protectedvirtual

Reimplemented Function

Reimplemented from QAbstractScrollArea.

Definition at line 1680 of file qtextedit.cpp.

1681 {
1682  Q_D(QTextEdit);
1683  d->autoScrollDragPos = e->pos();
1684  if (!d->autoScrollTimer.isActive())
1685  d->autoScrollTimer.start(100, this);
1686  d->sendControlEvent(e);
1687 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70
const QPoint & pos() const
Returns the position where the drop was made.
Definition: qevent.h:486

◆ dropEvent()

void QTextEdit::dropEvent ( QDropEvent e)
protectedvirtual

Reimplemented Function

Reimplemented from QAbstractScrollArea.

Definition at line 1691 of file qtextedit.cpp.

1692 {
1693  Q_D(QTextEdit);
1694  d->inDrag = false;
1695  d->autoScrollTimer.stop();
1696  d->sendControlEvent(e);
1697 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ ensureCursorVisible()

void QTextEdit::ensureCursorVisible ( )

Ensures that the cursor is visible by scrolling the text edit if necessary.

Definition at line 2743 of file qtextedit.cpp.

Referenced by event(), inputMethodEvent(), mouseReleaseEvent(), and showEvent().

2744 {
2745  Q_D(QTextEdit);
2746  d->control->ensureCursorVisible();
2747 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ event()

bool QTextEdit::event ( QEvent e)
protectedvirtual
Warning
This function is not part of the public interface.

Reimplemented from QAbstractScrollArea.

Reimplemented in QTextBrowser.

Definition at line 1071 of file qtextedit.cpp.

Referenced by QTextBrowser::event().

1072 {
1073  Q_D(QTextEdit);
1074 #ifndef QT_NO_CONTEXTMENU
1075  if (e->type() == QEvent::ContextMenu
1076  && static_cast<QContextMenuEvent *>(e)->reason() == QContextMenuEvent::Keyboard) {
1077  Q_D(QTextEdit);
1079  const QPoint cursorPos = cursorRect().center();
1080  QContextMenuEvent ce(QContextMenuEvent::Keyboard, cursorPos, d->viewport->mapToGlobal(cursorPos));
1081  ce.setAccepted(e->isAccepted());
1082  const bool result = QAbstractScrollArea::event(&ce);
1083  e->setAccepted(ce.isAccepted());
1084  return result;
1085  } else if (e->type() == QEvent::ShortcutOverride
1086  || e->type() == QEvent::ToolTip) {
1087  d->sendControlEvent(e);
1088  }
1089 #endif // QT_NO_CONTEXTMENU
1090 #ifdef QT_KEYPAD_NAVIGATION
1091  if (e->type() == QEvent::EnterEditFocus || e->type() == QEvent::LeaveEditFocus) {
1092  if (QApplication::keypadNavigationEnabled())
1093  d->sendControlEvent(e);
1094  }
1095 #endif
1096  return QAbstractScrollArea::event(e);
1097 }
double d
Definition: qnumeric_p.h:62
QRect cursorRect() const
returns a rectangle (in viewport coordinates) that includes the cursor of the text edit...
Definition: qtextedit.cpp:1888
The QContextMenuEvent class contains parameters that describe a context menu event.
Definition: qevent.h:396
void setAccepted(bool accepted)
Definition: qcoreevent.h:306
void ensureCursorVisible()
Ensures that the cursor is visible by scrolling the text edit if necessary.
Definition: qtextedit.cpp:2743
#define Q_D(Class)
Definition: qglobal.h:2482
bool isAccepted() const
Definition: qcoreevent.h:307
QPoint center() const
Returns the center point of the rectangle.
Definition: qrect.h:300
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
bool event(QEvent *)
Reimplemented Function
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ extraSelections()

QList< QTextEdit::ExtraSelection > QTextEdit::extraSelections ( ) const

Returns previously set extra selections.

Since
4.2
See also
setExtraSelections()

Definition at line 2062 of file qtextedit.cpp.

2063 {
2064  Q_D(const QTextEdit);
2065  return d->control->extraSelections();
2066 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ find()

bool QTextEdit::find ( const QString exp,
QTextDocument::FindFlags  options = 0 
)

Finds the next occurrence of the string, exp, using the given options.

Use the find() overload that takes a QTextDocument::FindFlags argument.

Returns true if exp was found and changes the cursor to select the match; otherwise returns false.

Definition at line 2518 of file qtextedit.cpp.

2519 {
2520  Q_D(QTextEdit);
2521  return d->control->find(exp, options);
2522 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ focusInEvent()

void QTextEdit::focusInEvent ( QFocusEvent e)
protectedvirtual

Reimplemented Function

Reimplemented from QWidget.

Definition at line 1746 of file qtextedit.cpp.

1747 {
1748  Q_D(QTextEdit);
1749  if (e->reason() == Qt::MouseFocusReason) {
1750  d->clickCausedFocus = 1;
1751  }
1753  d->sendControlEvent(e);
1754 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
Qt::FocusReason reason()
Definition: qevent.cpp:1197
virtual void focusInEvent(QFocusEvent *)
This event handler can be reimplemented in a subclass to receive keyboard focus events (focus receive...
Definition: qwidget.cpp:9431
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ focusNextPrevChild()

bool QTextEdit::focusNextPrevChild ( bool  next)
protectedvirtual

Reimplemented Function

Reimplemented from QWidget.

Reimplemented in QTextBrowser.

Definition at line 1627 of file qtextedit.cpp.

Referenced by QTextBrowser::focusNextPrevChild().

1628 {
1629  Q_D(const QTextEdit);
1630  if (!d->tabChangesFocus && d->control->textInteractionFlags() & Qt::TextEditable)
1631  return false;
1633 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
virtual bool focusNextPrevChild(bool next)
Finds a new widget to give the keyboard focus to, as appropriate for Tab and Shift+Tab, and returns true if it can find a new widget, or false if it can&#39;t.
Definition: qwidget.cpp:6836
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ focusOutEvent()

void QTextEdit::focusOutEvent ( QFocusEvent e)
protectedvirtual

Reimplemented Function

Reimplemented from QWidget.

Reimplemented in QTextBrowser.

Definition at line 1758 of file qtextedit.cpp.

Referenced by QTextBrowser::focusOutEvent().

1759 {
1760  Q_D(QTextEdit);
1762  d->sendControlEvent(e);
1763 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
virtual void focusOutEvent(QFocusEvent *)
This event handler can be reimplemented in a subclass to receive keyboard focus events (focus lost) f...
Definition: qwidget.cpp:9457
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ fontFamily()

QString QTextEdit::fontFamily ( ) const

Returns the font family of the current format.

See also
setFontFamily() setCurrentFont() setFontPointSize()

Definition at line 674 of file qtextedit.cpp.

675 {
676  Q_D(const QTextEdit);
677  return d->control->textCursor().charFormat().fontFamily();
678 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ fontItalic()

bool QTextEdit::fontItalic ( ) const

Returns true if the font of the current format is italic; otherwise returns false.

See also
setFontItalic()

Definition at line 709 of file qtextedit.cpp.

710 {
711  Q_D(const QTextEdit);
712  return d->control->textCursor().charFormat().fontItalic();
713 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ fontPointSize()

qreal QTextEdit::fontPointSize ( ) const

Returns the point size of the font of the current format.

See also
setFontFamily() setCurrentFont() setFontPointSize()

Definition at line 663 of file qtextedit.cpp.

664 {
665  Q_D(const QTextEdit);
666  return d->control->textCursor().charFormat().fontPointSize();
667 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ fontUnderline()

bool QTextEdit::fontUnderline ( ) const

Returns true if the font of the current format is underlined; otherwise returns false.

See also
setFontUnderline()

Definition at line 697 of file qtextedit.cpp.

698 {
699  Q_D(const QTextEdit);
700  return d->control->textCursor().charFormat().fontUnderline();
701 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ fontWeight()

int QTextEdit::fontWeight ( ) const

Returns the font weight of the current format.

See also
setFontWeight() setCurrentFont() setFontPointSize() QFont::Weight

Definition at line 685 of file qtextedit.cpp.

686 {
687  Q_D(const QTextEdit);
688  return d->control->textCursor().charFormat().fontWeight();
689 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ inputMethodEvent()

void QTextEdit::inputMethodEvent ( QInputMethodEvent e)
protectedvirtual

Reimplemented Function

em>Reimplemented Function

Reimplemented from QWidget.

Definition at line 1703 of file qtextedit.cpp.

◆ inputMethodQuery()

QVariant QTextEdit::inputMethodQuery ( Qt::InputMethodQuery  query) const
protectedvirtual

This method is only relevant for input widgets.

It is used by the input method to query a set of properties of the widget to be able to support complex input method operations as support for surrounding text and reconversions.

query specifies which property is queried.

See also
inputMethodEvent(), QInputMethodEvent, QInputContext, inputMethodHints

Reimplemented from QWidget.

Definition at line 1728 of file qtextedit.cpp.

1729 {
1730  Q_D(const QTextEdit);
1731  QVariant v = d->control->inputMethodQuery(property);
1732  const QPoint offset(-d->horizontalOffset(), -d->verticalOffset());
1733  if (v.type() == QVariant::RectF)
1734  v = v.toRectF().toRect().translated(offset);
1735  else if (v.type() == QVariant::PointF)
1736  v = v.toPointF().toPoint() + offset;
1737  else if (v.type() == QVariant::Rect)
1738  v = v.toRect().translated(offset);
1739  else if (v.type() == QVariant::Point)
1740  v = v.toPoint() + offset;
1741  return v;
1742 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
double d
Definition: qnumeric_p.h:62
QPointF toPointF() const
Returns the variant as a QPointF if the variant has type() Point or PointF ; otherwise returns a null...
Definition: qvariant.cpp:2509
QRect translated(int dx, int dy) const
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis...
Definition: qrect.h:328
QRectF toRectF() const
Returns the variant as a QRectF if the variant has type() Rect or RectF ; otherwise returns an invali...
Definition: qvariant.cpp:2463
#define Q_D(Class)
Definition: qglobal.h:2482
QRect toRect() const
Returns a QRect based on the values of this rectangle.
Definition: qrect.h:845
QRect toRect() const
Returns the variant as a QRect if the variant has type() Rect ; otherwise returns an invalid QRect...
Definition: qvariant.cpp:2416
QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
Definition: qpoint.h:376
Type type() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1901
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
QVariant property(const char *name) const
Returns the value of the object&#39;s name property.
Definition: qobject.cpp:3807
QPoint toPoint() const
Returns the variant as a QPoint if the variant has type() Point or PointF ; otherwise returns a null ...
Definition: qvariant.cpp:2400
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ insertFromMimeData()

void QTextEdit::insertFromMimeData ( const QMimeData source)
protectedvirtual

This function inserts the contents of the MIME data object, specified by source, into the text edit at the current cursor position.

It is called whenever text is inserted as the result of a clipboard paste operation, or when the text edit accepts data from a drag and drop operation.

Reimplement this function to enable drag and drop support for additional MIME types.

Definition at line 2108 of file qtextedit.cpp.

Referenced by QTextEditControl::insertFromMimeData().

2109 {
2110  Q_D(QTextEdit);
2111  d->control->QTextControl::insertFromMimeData(source);
2112 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ insertHtml

void QTextEdit::insertHtml ( const QString text)
slot

Convenience slot that inserts text which is assumed to be of html formatting at the current cursor position.

It is equivalent to:

edit->textCursor().insertHtml(fragment);
Note
When using this function with a style sheet, the style sheet will only apply to the current block in the document. In order to apply a style sheet throughout a document, use QTextDocument::setDefaultStyleSheet() instead.

Definition at line 2265 of file qtextedit.cpp.

2266 {
2267  Q_D(QTextEdit);
2268  d->control->insertHtml(text);
2269 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ insertPlainText

void QTextEdit::insertPlainText ( const QString text)
slot

Convenience slot that inserts text at the current cursor position.

It is equivalent to

edit->textCursor().insertText(text);

Definition at line 2245 of file qtextedit.cpp.

2246 {
2247  Q_D(QTextEdit);
2248  d->control->insertPlainText(text);
2249 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ isReadOnly()

bool QTextEdit::isReadOnly ( ) const

Definition at line 2127 of file qtextedit.cpp.

Referenced by append(), mouseReleaseEvent(), and shouldEnableInputMethod().

2128 {
2129  Q_D(const QTextEdit);
2130  return !(d->control->textInteractionFlags() & Qt::TextEditable);
2131 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ isUndoRedoEnabled()

bool QTextEdit::isUndoRedoEnabled ( ) const
inline

Definition at line 173 of file qtextedit.h.

174  { return document()->isUndoRedoEnabled(); }
bool isUndoRedoEnabled() const
QTextDocument * document() const
Returns a pointer to the underlying document.
Definition: qtextedit.cpp:804

◆ keyPressEvent()

void QTextEdit::keyPressEvent ( QKeyEvent e)
protectedvirtual

Reimplemented Function

Reimplemented from QAbstractScrollArea.

Reimplemented in QTextBrowser.

Definition at line 1210 of file qtextedit.cpp.

Referenced by QTextBrowser::keyPressEvent().

1211 {
1212  Q_D(QTextEdit);
1213 
1214 #ifdef QT_KEYPAD_NAVIGATION
1215  switch (e->key()) {
1216  case Qt::Key_Select:
1217  if (QApplication::keypadNavigationEnabled()) {
1218  // code assumes linksaccessible + editable isn't meaningful
1219  if (d->control->textInteractionFlags() & Qt::TextEditable) {
1220  setEditFocus(!hasEditFocus());
1221  } else {
1222  if (!hasEditFocus())
1223  setEditFocus(true);
1224  else {
1225  QTextCursor cursor = d->control->textCursor();
1226  QTextCharFormat charFmt = cursor.charFormat();
1227  if (!(d->control->textInteractionFlags() & Qt::LinksAccessibleByKeyboard)
1228  || !cursor.hasSelection() || charFmt.anchorHref().isEmpty()) {
1229  e->accept();
1230  return;
1231  }
1232  }
1233  }
1234  }
1235  break;
1236  case Qt::Key_Back:
1237  case Qt::Key_No:
1238  if (!QApplication::keypadNavigationEnabled()
1239  || (QApplication::keypadNavigationEnabled() && !hasEditFocus())) {
1240  e->ignore();
1241  return;
1242  }
1243  break;
1244  default:
1245  if (QApplication::keypadNavigationEnabled()) {
1246  if (!hasEditFocus() && !(e->modifiers() & Qt::ControlModifier)) {
1247  if (e->text()[0].isPrint())
1248  setEditFocus(true);
1249  else {
1250  e->ignore();
1251  return;
1252  }
1253  }
1254  }
1255  break;
1256  }
1257 #endif
1258 #ifndef QT_NO_SHORTCUT
1259 
1260  Qt::TextInteractionFlags tif = d->control->textInteractionFlags();
1261 
1262  if (tif & Qt::TextSelectableByKeyboard){
1264  e->accept();
1266  return;
1267  } else if (e ==QKeySequence::SelectNextPage) {
1268  e->accept();
1270  return;
1271  }
1272  }
1273  if (tif & (Qt::TextSelectableByKeyboard | Qt::TextEditable)) {
1275  e->accept();
1277  return;
1278  } else if (e == QKeySequence::MoveToNextPage) {
1279  e->accept();
1281  return;
1282  }
1283  }
1284 
1285  if (!(tif & Qt::TextEditable)) {
1286  switch (e->key()) {
1287  case Qt::Key_Space:
1288  e->accept();
1289  if (e->modifiers() & Qt::ShiftModifier)
1290  d->vbar->triggerAction(QAbstractSlider::SliderPageStepSub);
1291  else
1292  d->vbar->triggerAction(QAbstractSlider::SliderPageStepAdd);
1293  break;
1294  default:
1295  d->sendControlEvent(e);
1296  if (!e->isAccepted() && e->modifiers() == Qt::NoModifier) {
1297  if (e->key() == Qt::Key_Home) {
1298  d->vbar->triggerAction(QAbstractSlider::SliderToMinimum);
1299  e->accept();
1300  } else if (e->key() == Qt::Key_End) {
1301  d->vbar->triggerAction(QAbstractSlider::SliderToMaximum);
1302  e->accept();
1303  }
1304  }
1305  if (!e->isAccepted()) {
1307  }
1308  }
1309  return;
1310  }
1311 #endif // QT_NO_SHORTCUT
1312 
1313  {
1314  QTextCursor cursor = d->control->textCursor();
1315  const QString text = e->text();
1316  if (cursor.atBlockStart()
1317  && (d->autoFormatting & AutoBulletList)
1318  && (text.length() == 1)
1319  && (text.at(0) == QLatin1Char('-') || text.at(0) == QLatin1Char('*'))
1320  && (!cursor.currentList())) {
1321 
1322  d->createAutoBulletList();
1323  e->accept();
1324  return;
1325  }
1326  }
1327 
1328  d->sendControlEvent(e);
1329 #ifdef QT_KEYPAD_NAVIGATION
1330  if (!e->isAccepted()) {
1331  switch (e->key()) {
1332  case Qt::Key_Up:
1333  case Qt::Key_Down:
1334  if (QApplication::keypadNavigationEnabled()) {
1335  // Cursor position didn't change, so we want to leave
1336  // these keys to change focus.
1337  e->ignore();
1338  return;
1339  }
1340  break;
1341  case Qt::Key_Back:
1342  if (!e->isAutoRepeat()) {
1343  if (QApplication::keypadNavigationEnabled()) {
1344  if (document()->isEmpty() || !(d->control->textInteractionFlags() & Qt::TextEditable)) {
1345  setEditFocus(false);
1346  e->accept();
1347  } else if (!d->deleteAllTimer.isActive()) {
1348  e->accept();
1349  d->deleteAllTimer.start(750, this);
1350  }
1351  } else {
1352  e->ignore();
1353  return;
1354  }
1355  }
1356  break;
1357  default: break;
1358  }
1359  }
1360 #endif
1361 }
double d
Definition: qnumeric_p.h:62
The QTextCharFormat class provides formatting information for characters in a QTextDocument.
Definition: qtextformat.h:372
QTextCharFormat charFormat() const
Returns the format of the character immediately before the cursor position().
QCursor cursor() const
const QChar at(int i) const
Returns the character at the given index position in the string.
Definition: qstring.h:698
bool isEmpty() const
Returns true if the document is empty; otherwise returns false.
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
bool atBlockStart() const
Returns true if the cursor is at the start of a block; otherwise returns false.
QString anchorHref() const
Returns the text format&#39;s hypertext link, or an empty string if none has been set.
Definition: qtextformat.h:506
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_D(Class)
Definition: qglobal.h:2482
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately after the event occurred.
Definition: qevent.cpp:999
int key() const
Returns the code of the key that was pressed or released.
Definition: qevent.h:231
bool isAccepted() const
Definition: qcoreevent.h:307
bool hasSelection() const
Returns true if the cursor contains a selection; otherwise returns false.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
The QTextCursor class offers an API to access and modify QTextDocuments.
Definition: qtextcursor.h:70
QTextList * currentList() const
Returns the current list if the cursor position() is inside a block that is part of a list; otherwise...
QString text() const
Returns the Unicode text that this key generated.
Definition: qevent.h:236
QTextDocument * document() const
Returns a pointer to the underlying document.
Definition: qtextedit.cpp:804
bool isAutoRepeat() const
Returns true if this event comes from an auto-repeating key; returns false if it comes from an initia...
Definition: qevent.h:237
void ignore()
Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false).
Definition: qcoreevent.h:310
void accept()
Sets the accept flag of the event object, the equivalent of calling setAccepted(true).
Definition: qcoreevent.h:309
void keyPressEvent(QKeyEvent *)
This function is called with key event e when key presses occur.
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70
#define text
Definition: qobjectdefs.h:80

◆ keyReleaseEvent()

void QTextEdit::keyReleaseEvent ( QKeyEvent e)
protectedvirtual

Reimplemented Function

Reimplemented from QWidget.

Definition at line 1365 of file qtextedit.cpp.

1366 {
1367 #ifdef QT_KEYPAD_NAVIGATION
1368  Q_D(QTextEdit);
1369  if (QApplication::keypadNavigationEnabled()) {
1370  if (!e->isAutoRepeat() && e->key() == Qt::Key_Back
1371  && d->deleteAllTimer.isActive()) {
1372  d->deleteAllTimer.stop();
1373  QTextCursor cursor = d->control->textCursor();
1374  QTextBlockFormat blockFmt = cursor.blockFormat();
1375 
1376  QTextList *list = cursor.currentList();
1377  if (list && cursor.atBlockStart()) {
1378  list->remove(cursor.block());
1379  } else if (cursor.atBlockStart() && blockFmt.indent() > 0) {
1380  blockFmt.setIndent(blockFmt.indent() - 1);
1381  cursor.setBlockFormat(blockFmt);
1382  } else {
1383  cursor.deletePreviousChar();
1384  }
1385  setTextCursor(cursor);
1386  e->accept();
1387  return;
1388  }
1389  }
1390 #endif
1391  e->ignore();
1392 }
double d
Definition: qnumeric_p.h:62
QCursor cursor() const
QTextBlockFormat blockFormat() const
Returns the block format of the block the cursor is in.
bool atBlockStart() const
Returns true if the cursor is at the start of a block; otherwise returns false.
int indent() const
Returns the paragraph&#39;s indent.
Definition: qtextformat.h:590
#define Q_D(Class)
Definition: qglobal.h:2482
void setTextCursor(const QTextCursor &cursor)
Sets the visible cursor.
Definition: qtextedit.cpp:813
int key() const
Returns the code of the key that was pressed or released.
Definition: qevent.h:231
void setBlockFormat(const QTextBlockFormat &format)
Sets the block format of the current block (or all blocks that are contained in the selection) to for...
The QTextCursor class offers an API to access and modify QTextDocuments.
Definition: qtextcursor.h:70
QTextList * currentList() const
Returns the current list if the cursor position() is inside a block that is part of a list; otherwise...
QTextBlock block() const
Returns the block that contains the cursor.
void remove(const QTextBlock &)
Removes the given block from the list.
Definition: qtextlist.cpp:319
void deletePreviousChar()
If there is no selected text, deletes the character before the current cursor position; otherwise del...
The QTextBlockFormat class provides formatting information for blocks of text in a QTextDocument...
Definition: qtextformat.h:545
bool isAutoRepeat() const
Returns true if this event comes from an auto-repeating key; returns false if it comes from an initia...
Definition: qevent.h:237
void setIndent(int indent)
Sets the paragraph&#39;s indentation.
Definition: qtextformat.h:622
The QTextList class provides a decorated list of items in a QTextDocument.
Definition: qtextlist.h:57
void ignore()
Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false).
Definition: qcoreevent.h:310
void accept()
Sets the accept flag of the event object, the equivalent of calling setAccepted(true).
Definition: qcoreevent.h:309
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ lineWrapColumnOrWidth()

int QTextEdit::lineWrapColumnOrWidth ( ) const

◆ lineWrapMode()

LineWrapMode QTextEdit::lineWrapMode ( ) const

Referenced by setTabChangesFocus().

◆ loadResource()

QVariant QTextEdit::loadResource ( int  type,
const QUrl name 
)
virtual

Loads the resource specified by the given type and name.

This function is an extension of QTextDocument::loadResource().

See also
QTextDocument::loadResource()

Reimplemented in QTextBrowser.

Definition at line 1401 of file qtextedit.cpp.

1402 {
1403  Q_UNUSED(type);
1404  Q_UNUSED(name);
1405  return QVariant();
1406 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
int type
Definition: qmetatype.cpp:239
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ mergeCurrentCharFormat()

void QTextEdit::mergeCurrentCharFormat ( const QTextCharFormat modifier)

Merges the properties specified in modifier into the current character format by calling QTextCursor::mergeCharFormat on the editor's cursor.

If the editor has a selection then the properties of modifier are directly applied to the selection.

See also
QTextCursor::mergeCharFormat()

Definition at line 2183 of file qtextedit.cpp.

Referenced by setCurrentFont(), setFontFamily(), setFontItalic(), setFontPointSize(), setFontUnderline(), setFontWeight(), setTextBackgroundColor(), and setTextColor().

2184 {
2185  Q_D(QTextEdit);
2186  d->control->mergeCurrentCharFormat(modifier);
2187 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ mouseDoubleClickEvent()

void QTextEdit::mouseDoubleClickEvent ( QMouseEvent e)
protectedvirtual

Reimplemented Function

Reimplemented from QAbstractScrollArea.

Definition at line 1619 of file qtextedit.cpp.

1620 {
1621  Q_D(QTextEdit);
1622  d->sendControlEvent(e);
1623 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ mouseMoveEvent()

void QTextEdit::mouseMoveEvent ( QMouseEvent e)
protectedvirtual

Reimplemented Function

Reimplemented from QAbstractScrollArea.

Reimplemented in QTextBrowser.

Definition at line 1587 of file qtextedit.cpp.

Referenced by QTextBrowser::mouseMoveEvent(), and timerEvent().

1588 {
1589  Q_D(QTextEdit);
1590  d->inDrag = false; // paranoia
1591  const QPoint pos = e->pos();
1592  d->sendControlEvent(e);
1593  if (!(e->buttons() & Qt::LeftButton))
1594  return;
1595  QRect visible = d->viewport->rect();
1596  if (visible.contains(pos))
1597  d->autoScrollTimer.stop();
1598  else if (!d->autoScrollTimer.isActive())
1599  d->autoScrollTimer.start(100, this);
1600 }
QPoint pos() const
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
const QPoint & pos() const
Returns the position of the mouse cursor, relative to the widget that received the event...
Definition: qevent.h:95
bool visible
whether the widget is visible
Definition: qwidget.h:191
bool contains(const QPoint &p, bool proper=false) const
Returns true if the given point is inside or on the edge of the rectangle, otherwise returns false...
Definition: qrect.cpp:1101
Qt::MouseButtons buttons() const
Returns the button state when the event was generated.
Definition: qevent.h:102
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ mousePressEvent()

void QTextEdit::mousePressEvent ( QMouseEvent e)
protectedvirtual

Reimplemented Function

Reimplemented from QAbstractScrollArea.

Reimplemented in QTextBrowser.

Definition at line 1575 of file qtextedit.cpp.

Referenced by QTextBrowser::mousePressEvent().

1576 {
1577  Q_D(QTextEdit);
1578 #ifdef QT_KEYPAD_NAVIGATION
1579  if (QApplication::keypadNavigationEnabled() && !hasEditFocus())
1580  setEditFocus(true);
1581 #endif
1582  d->sendControlEvent(e);
1583 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ mouseReleaseEvent()

void QTextEdit::mouseReleaseEvent ( QMouseEvent e)
protectedvirtual

Reimplemented Function

Reimplemented from QAbstractScrollArea.

Reimplemented in QTextBrowser.

Definition at line 1604 of file qtextedit.cpp.

Referenced by QTextBrowser::mouseReleaseEvent().

1605 {
1606  Q_D(QTextEdit);
1607  d->sendControlEvent(e);
1608  if (d->autoScrollTimer.isActive()) {
1609  d->autoScrollTimer.stop();
1611  }
1612  if (!isReadOnly() && rect().contains(e->pos()))
1613  d->handleSoftwareInputPanel(e->button(), d->clickCausedFocus);
1614  d->clickCausedFocus = 0;
1615 }
double d
Definition: qnumeric_p.h:62
void ensureCursorVisible()
Ensures that the cursor is visible by scrolling the text edit if necessary.
Definition: qtextedit.cpp:2743
#define Q_D(Class)
Definition: qglobal.h:2482
const QPoint & pos() const
Returns the position of the mouse cursor, relative to the widget that received the event...
Definition: qevent.h:95
Qt::MouseButton button() const
Returns the button that caused the event.
Definition: qevent.h:101
QRect rect() const
bool isReadOnly() const
Definition: qtextedit.cpp:2127
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ moveCursor()

void QTextEdit::moveCursor ( QTextCursor::MoveOperation  operation,
QTextCursor::MoveMode  mode = QTextCursor::MoveAnchor 
)

Moves the cursor by performing the given operation.

Since
4.2

If mode is QTextCursor::KeepAnchor, the cursor selects the text it moves over. This is the same effect that the user achieves when they hold down the Shift key and move the cursor with the cursor keys.

See also
QTextCursor::movePosition()

Definition at line 2349 of file qtextedit.cpp.

Referenced by setText().

2350 {
2351  Q_D(QTextEdit);
2352  d->control->moveCursor(operation, mode);
2353 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ overwriteMode()

bool QTextEdit::overwriteMode ( ) const

Referenced by anchorAt().

◆ paintEvent()

void QTextEdit::paintEvent ( QPaintEvent event)
protectedvirtual

This event handler can be reimplemented in a subclass to receive paint events passed in event.

It is usually unnecessary to reimplement this function in a subclass of QTextEdit.

Warning
The underlying text document must not be modified from within a reimplementation of this function.

Reimplemented from QAbstractScrollArea.

Reimplemented in QTextBrowser.

Definition at line 1539 of file qtextedit.cpp.

1540 {
1541  Q_D(QTextEdit);
1542  QPainter p(d->viewport);
1543  d->paint(&p, e);
1544 }
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ paste

void QTextEdit::paste ( )
slot

Pastes the text from the clipboard into the text edit at the current cursor position.

If there is no text in the clipboard nothing happens.

To change the behavior of this function, i.e. to modify what QTextEdit can paste and how it is being pasted, reimplement the virtual canInsertFromMimeData() and insertFromMimeData() functions.

See also
cut() copy()

Definition at line 1036 of file qtextedit.cpp.

Referenced by QAccessibleTextEdit::pasteText().

1037 {
1038  Q_D(QTextEdit);
1039  d->control->paste();
1040 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ print()

void QTextEdit::print ( QPrinter printer) const

Convenience function to print the text edit's document to the given printer.

Since
4.3 This is equivalent to calling the print method on the document directly except that this function also supports QPrinter::Selection as print range.
See also
QTextDocument::print()

Definition at line 2380 of file qtextedit.cpp.

2381 {
2382  Q_D(const QTextEdit);
2383  d->control->print(printer);
2384 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ redo

void QTextEdit::redo ( )
slot

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Redoes the last operation.

Since
4.2

If there is no operation to redo, i.e. there is no redo step in the undo/redo history, nothing happens.

See also
undo()

Definition at line 962 of file qtextedit.cpp.

963 {
964  Q_D(QTextEdit);
965  d->control->redo();
966 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ redoAvailable

void QTextEdit::redoAvailable ( bool  b)
signal

This signal is emitted whenever redo operations become available (available is true) or unavailable (available is false).

◆ resizeEvent()

void QTextEdit::resizeEvent ( QResizeEvent e)
protectedvirtual

Reimplemented Function

Reimplemented from QAbstractScrollArea.

Definition at line 1410 of file qtextedit.cpp.

1411 {
1412  Q_D(QTextEdit);
1413 
1414  if (d->lineWrap == NoWrap) {
1415  QTextDocument *doc = d->control->document();
1416  QVariant alignmentProperty = doc->documentLayout()->property("contentHasAlignment");
1417 
1418  if (!doc->pageSize().isNull()
1419  && alignmentProperty.type() == QVariant::Bool
1420  && !alignmentProperty.toBool()) {
1421 
1422  d->_q_adjustScrollbars();
1423  return;
1424  }
1425  }
1426 
1427  if (d->lineWrap != FixedPixelWidth
1428  && e->oldSize().width() != e->size().width())
1429  d->relayoutDocument();
1430  else
1431  d->_q_adjustScrollbars();
1432 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
double d
Definition: qnumeric_p.h:62
QSizeF pageSize
the page size that should be used for laying out the document
bool isNull() const
Returns true if both the width and height are +0.
Definition: qsize.h:275
bool toBool() const
Returns the variant as a bool if the variant has type() Bool.
Definition: qvariant.cpp:2691
#define Q_D(Class)
Definition: qglobal.h:2482
int width() const
Returns the width.
Definition: qsize.h:126
const QSize & oldSize() const
Returns the old size of the widget.
Definition: qevent.h:356
const QSize & size() const
Returns the new size of the widget.
Definition: qevent.h:355
Type type() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1901
QAbstractTextDocumentLayout * documentLayout() const
Returns the document layout for this document.
QVariant property(const char *name) const
Returns the value of the object&#39;s name property.
Definition: qobject.cpp:3807
The QTextDocument class holds formatted text that can be viewed and edited using a QTextEdit...
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ scrollContentsBy()

void QTextEdit::scrollContentsBy ( int  dx,
int  dy 
)
protectedvirtual

em>Reimplemented Function

Reimplemented from QAbstractScrollArea.

Definition at line 1718 of file qtextedit.cpp.

◆ scrollToAnchor

void QTextEdit::scrollToAnchor ( const QString name)
slot

Scrolls the text edit so that the anchor with the given name is visible; does nothing if the name is empty, or is already visible, or isn't found.

Definition at line 2277 of file qtextedit.cpp.

Referenced by showEvent().

2278 {
2279  Q_D(QTextEdit);
2280  if (name.isEmpty())
2281  return;
2282 
2283  if (!isVisible()) {
2284  d->anchorToScrollToWhenVisible = name;
2285  return;
2286  }
2287 
2288  QPointF p = d->control->anchorPosition(name);
2289  const int newPosition = qRound(p.y());
2290  if ( d->vbar->maximum() < newPosition )
2291  d->_q_adjustScrollbars();
2292  d->vbar->setValue(newPosition);
2293 }
double d
Definition: qnumeric_p.h:62
bool isVisible() const
Definition: qwidget.h:1005
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
#define Q_D(Class)
Definition: qglobal.h:2482
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
const char * name
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ selectAll

void QTextEdit::selectAll ( )
slot

Selects all text.

See also
copy() cut() textCursor()

Definition at line 1063 of file qtextedit.cpp.

1064 {
1065  Q_D(QTextEdit);
1066  d->control->selectAll();
1067 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ selectionChanged

void QTextEdit::selectionChanged ( )
signal

This signal is emitted whenever the selection changes.

See also
copyAvailable()

◆ setAcceptRichText()

void QTextEdit::setAcceptRichText ( bool  accept)

Definition at line 2005 of file qtextedit.cpp.

2006 {
2007  Q_D(QTextEdit);
2008  d->control->setAcceptRichText(accept);
2009 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ setAlignment

void QTextEdit::setAlignment ( Qt::Alignment  a)
slot

Sets the alignment of the current paragraph to a.

Valid alignments are Qt::AlignLeft, Qt::AlignRight, Qt::AlignJustify and Qt::AlignCenter (which centers horizontally).

Definition at line 759 of file qtextedit.cpp.

760 {
761  Q_D(QTextEdit);
762  QTextBlockFormat fmt;
763  fmt.setAlignment(a);
764  QTextCursor cursor = d->control->textCursor();
765  cursor.mergeBlockFormat(fmt);
766  d->control->setTextCursor(cursor);
767 }
double d
Definition: qnumeric_p.h:62
QCursor cursor() const
long ASN1_INTEGER_get ASN1_INTEGER * a
void mergeBlockFormat(const QTextBlockFormat &modifier)
Modifies the block format of the current block (or all blocks that are contained in the selection) wi...
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextCursor class offers an API to access and modify QTextDocuments.
Definition: qtextcursor.h:70
void setAlignment(Qt::Alignment alignment)
Sets the paragraph&#39;s alignment.
Definition: qtextformat.h:619
The QTextBlockFormat class provides formatting information for blocks of text in a QTextDocument...
Definition: qtextformat.h:545
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ setAutoFormatting()

void QTextEdit::setAutoFormatting ( AutoFormatting  features)

Definition at line 2231 of file qtextedit.cpp.

2232 {
2233  Q_D(QTextEdit);
2234  d->autoFormatting = features;
2235 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ setCurrentCharFormat()

void QTextEdit::setCurrentCharFormat ( const QTextCharFormat format)

Sets the char format that is be used when inserting new text to format by calling QTextCursor::setCharFormat() on the editor's cursor.

If the editor has a selection then the char format is directly applied to the selection.

Definition at line 2195 of file qtextedit.cpp.

2196 {
2197  Q_D(QTextEdit);
2198  d->control->setCurrentCharFormat(format);
2199 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ setCurrentFont

void QTextEdit::setCurrentFont ( const QFont f)
slot

Sets the font of the current format to f.

See also
currentFont() setFontPointSize() setFontFamily()

Definition at line 936 of file qtextedit.cpp.

937 {
938  QTextCharFormat fmt;
939  fmt.setFont(f);
941 }
The QTextCharFormat class provides formatting information for characters in a QTextDocument.
Definition: qtextformat.h:372
void setFont(const QFont &font)
Sets the text format&#39;s font.
void mergeCurrentCharFormat(const QTextCharFormat &modifier)
Merges the properties specified in modifier into the current character format by calling QTextCursor:...
Definition: qtextedit.cpp:2183

◆ setCursorWidth()

void QTextEdit::setCursorWidth ( int  width)

Definition at line 1979 of file qtextedit.cpp.

1980 {
1981  Q_D(QTextEdit);
1982  d->control->setCursorWidth(width);
1983 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
int width() const
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ setDocument()

void QTextEdit::setDocument ( QTextDocument document)

Makes document the new document of the text editor.

Note
The editor does not take ownership of the document unless it is the document's parent object. The parent object of the provided document remains the owner of the object.

The editor does not delete the current document, even if it is a child of the editor.

See also
document()

Definition at line 791 of file qtextedit.cpp.

792 {
793  Q_D(QTextEdit);
794  d->control->setDocument(document);
795  d->updateDefaultTextOption();
796  d->relayoutDocument();
797 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ setDocumentTitle()

void QTextEdit::setDocumentTitle ( const QString title)
inline

Definition at line 168 of file qtextedit.h.

void setMetaInformation(MetaInformation info, const QString &)
Sets the document&#39;s meta information of the type specified by info to the given string.
QTextDocument * document() const
Returns a pointer to the underlying document.
Definition: qtextedit.cpp:804

◆ setExtraSelections()

void QTextEdit::setExtraSelections ( const QList< ExtraSelection > &  selections)

This function allows temporarily marking certain regions in the document with a given color, specified as selections.

Since
4.2 This can be useful for example in a programming editor to mark a whole line of text with a given background color to indicate the existence of a breakpoint.
See also
QTextEdit::ExtraSelection, extraSelections()

Definition at line 2047 of file qtextedit.cpp.

2048 {
2049  Q_D(QTextEdit);
2050  d->control->setExtraSelections(selections);
2051 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ setFontFamily

void QTextEdit::setFontFamily ( const QString fontFamily)
slot

Sets the font family of the current format to fontFamily.

See also
fontFamily() setCurrentFont()

Definition at line 835 of file qtextedit.cpp.

836 {
837  QTextCharFormat fmt;
838  fmt.setFontFamily(fontFamily);
840 }
The QTextCharFormat class provides formatting information for characters in a QTextDocument.
Definition: qtextformat.h:372
void mergeCurrentCharFormat(const QTextCharFormat &modifier)
Merges the properties specified in modifier into the current character format by calling QTextCursor:...
Definition: qtextedit.cpp:2183
void setFontFamily(const QString &family)
Sets the text format&#39;s font family.
Definition: qtextformat.h:401

◆ setFontItalic

void QTextEdit::setFontItalic ( bool  italic)
slot

If italic is true, sets the current format to italic; otherwise sets the current format to non-italic.

See also
fontItalic()

Definition at line 895 of file qtextedit.cpp.

896 {
897  QTextCharFormat fmt;
898  fmt.setFontItalic(italic);
900 }
void setFontItalic(bool italic)
If italic is true, sets the text format&#39;s font to be italic; otherwise the font will be non-italic...
Definition: qtextformat.h:415
The QTextCharFormat class provides formatting information for characters in a QTextDocument.
Definition: qtextformat.h:372
void mergeCurrentCharFormat(const QTextCharFormat &modifier)
Merges the properties specified in modifier into the current character format by calling QTextCursor:...
Definition: qtextedit.cpp:2183

◆ setFontPointSize

void QTextEdit::setFontPointSize ( qreal  s)
slot

Sets the point size of the current format to s.

Note that if s is zero or negative, the behavior of this function is not defined.

See also
fontPointSize() setCurrentFont() setFontFamily()

Definition at line 850 of file qtextedit.cpp.

851 {
852  QTextCharFormat fmt;
853  fmt.setFontPointSize(s);
855 }
The QTextCharFormat class provides formatting information for characters in a QTextDocument.
Definition: qtextformat.h:372
void setFontPointSize(qreal size)
Sets the text format&#39;s font size.
Definition: qtextformat.h:406
void mergeCurrentCharFormat(const QTextCharFormat &modifier)
Merges the properties specified in modifier into the current character format by calling QTextCursor:...
Definition: qtextedit.cpp:2183

◆ setFontUnderline

void QTextEdit::setFontUnderline ( bool  underline)
slot

If underline is true, sets the current format to underline; otherwise sets the current format to non-underline.

See also
fontUnderline()

Definition at line 882 of file qtextedit.cpp.

883 {
884  QTextCharFormat fmt;
885  fmt.setFontUnderline(underline);
887 }
The QTextCharFormat class provides formatting information for characters in a QTextDocument.
Definition: qtextformat.h:372
void mergeCurrentCharFormat(const QTextCharFormat &modifier)
Merges the properties specified in modifier into the current character format by calling QTextCursor:...
Definition: qtextedit.cpp:2183
void setFontUnderline(bool underline)
If underline is true, sets the text format&#39;s font to be underlined; otherwise it is displayed non-und...
Definition: qtextformat.h:432

◆ setFontWeight

void QTextEdit::setFontWeight ( int  weight)
slot

Sets the font weight of the current format to the given weight, where the value used is in the range defined by the QFont::Weight enum.

See also
fontWeight(), setCurrentFont(), setFontFamily()

Definition at line 869 of file qtextedit.cpp.

870 {
871  QTextCharFormat fmt;
872  fmt.setFontWeight(w);
874 }
The QTextCharFormat class provides formatting information for characters in a QTextDocument.
Definition: qtextformat.h:372
void setFontWeight(int weight)
Sets the text format&#39;s font weight to weight.
Definition: qtextformat.h:411
void mergeCurrentCharFormat(const QTextCharFormat &modifier)
Merges the properties specified in modifier into the current character format by calling QTextCursor:...
Definition: qtextedit.cpp:2183

◆ setHtml

void QTextEdit::setHtml ( const QString text)
slot

Definition at line 1200 of file qtextedit.cpp.

Referenced by setText().

1201 {
1202  Q_D(QTextEdit);
1203  d->control->setHtml(text);
1204  d->preferRichText = true;
1205 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ setLineWrapColumnOrWidth()

void QTextEdit::setLineWrapColumnOrWidth ( int  w)

Definition at line 2479 of file qtextedit.cpp.

2480 {
2481  Q_D(QTextEdit);
2482  d->lineWrapColumnOrWidth = w;
2483  d->relayoutDocument();
2484 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ setLineWrapMode()

void QTextEdit::setLineWrapMode ( LineWrapMode  mode)

Definition at line 2445 of file qtextedit.cpp.

2446 {
2447  Q_D(QTextEdit);
2448  if (d->lineWrap == wrap)
2449  return;
2450  d->lineWrap = wrap;
2451  d->updateDefaultTextOption();
2452  d->relayoutDocument();
2453 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ setOverwriteMode()

void QTextEdit::setOverwriteMode ( bool  overwrite)

Definition at line 1931 of file qtextedit.cpp.

1932 {
1933  Q_D(QTextEdit);
1934  d->control->setOverwriteMode(overwrite);
1935 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ setPlainText

void QTextEdit::setPlainText ( const QString text)
slot

Changes the text of the text edit to the string text.

Any previous text is removed.

text is interpreted as plain text.

Note that the undo/redo history is cleared by this function.

See also
toPlainText()

Definition at line 1156 of file qtextedit.cpp.

Referenced by QMessageBoxDetailsText::setText(), and setText().

1157 {
1158  Q_D(QTextEdit);
1159  d->control->setPlainText(text);
1160  d->preferRichText = false;
1161 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ setReadOnly()

void QTextEdit::setReadOnly ( bool  ro)

Definition at line 2133 of file qtextedit.cpp.

Referenced by QMessageBoxDetailsText::QMessageBoxDetailsText().

2134 {
2135  Q_D(QTextEdit);
2136  Qt::TextInteractionFlags flags = Qt::NoTextInteraction;
2137  if (ro) {
2138  flags = Qt::TextSelectableByMouse;
2139 #ifndef QT_NO_TEXTBROWSER
2140  if (qobject_cast<QTextBrowser *>(this))
2141  flags |= Qt::TextBrowserInteraction;
2142 #endif
2143  } else {
2144  flags = Qt::TextEditorInteraction;
2145  }
2146  d->control->setTextInteractionFlags(flags);
2148 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
static bool shouldEnableInputMethod(QTextEdit *textedit)
Definition: qtextedit.cpp:77
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ setTabChangesFocus()

void QTextEdit::setTabChangesFocus ( bool  b)

Definition at line 2405 of file qtextedit.cpp.

2406 {
2407  Q_D(QTextEdit);
2408  d->tabChangesFocus = b;
2409 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ setTabStopWidth()

void QTextEdit::setTabStopWidth ( int  width)

Definition at line 1954 of file qtextedit.cpp.

1955 {
1956  Q_D(QTextEdit);
1957  QTextOption opt = d->control->document()->defaultTextOption();
1958  if (opt.tabStop() == width || width < 0)
1959  return;
1960  opt.setTabStop(width);
1961  d->control->document()->setDefaultTextOption(opt);
1962 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
qreal tabStop() const
Returns the distance in device units between tab stops.
Definition: qtextoption.h:124
int width() const
The QTextOption class provides a description of general rich text properties.
Definition: qtextoption.h:59
void setTabStop(qreal tabStop)
Sets the default distance in device units between tab stops to the value specified by tabStop...
Definition: qtextoption.h:154
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ setText

void QTextEdit::setText ( const QString text)
slot

Sets the text edit's text.

Since
4.2

The text can be plain text or HTML and the text edit will try to guess the right format.

Use setHtml() or setPlainText() directly to avoid text edit's guessing.

See also
toPlainText(), toHtml()

Definition at line 2591 of file qtextedit.cpp.

Referenced by DetailButton::setLabel(), and QAccessibleTextEdit::setText().

2592 {
2593  Q_D(QTextEdit);
2594  Qt::TextFormat format = d->textFormat;
2595  if (d->textFormat == Qt::AutoText)
2596  format = Qt::mightBeRichText(text) ? Qt::RichText : Qt::PlainText;
2597 #ifndef QT_NO_TEXTHTMLPARSER
2598  if (format == Qt::RichText || format == Qt::LogText)
2599  setHtml(text);
2600  else
2601 #endif
2602  setPlainText(text);
2603 }
double d
Definition: qnumeric_p.h:62
Q_GUI_EXPORT bool mightBeRichText(const QString &)
Returns true if the string text is likely to be rich text; otherwise returns false.
#define Q_D(Class)
Definition: qglobal.h:2482
TextFormat
Definition: qnamespace.h:1310
void setPlainText(const QString &text)
Changes the text of the text edit to the string text.
Definition: qtextedit.cpp:1156
void setHtml(const QString &text)
Definition: qtextedit.cpp:1200
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ setTextBackgroundColor

void QTextEdit::setTextBackgroundColor ( const QColor c)
slot

Sets the text background color of the current format to c.

Since
4.4
See also
textBackgroundColor()

Definition at line 924 of file qtextedit.cpp.

925 {
926  QTextCharFormat fmt;
927  fmt.setBackground(QBrush(c));
929 }
The QTextCharFormat class provides formatting information for characters in a QTextDocument.
Definition: qtextformat.h:372
void setBackground(const QBrush &brush)
Sets the brush use to paint the document&#39;s background to the brush specified.
Definition: qtextformat.h:343
void mergeCurrentCharFormat(const QTextCharFormat &modifier)
Merges the properties specified in modifier into the current character format by calling QTextCursor:...
Definition: qtextedit.cpp:2183
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76

◆ setTextColor

void QTextEdit::setTextColor ( const QColor c)
slot

Sets the text color of the current format to c.

See also
textColor()

Definition at line 907 of file qtextedit.cpp.

908 {
909  QTextCharFormat fmt;
910  fmt.setForeground(QBrush(c));
912 }
The QTextCharFormat class provides formatting information for characters in a QTextDocument.
Definition: qtextformat.h:372
void mergeCurrentCharFormat(const QTextCharFormat &modifier)
Merges the properties specified in modifier into the current character format by calling QTextCursor:...
Definition: qtextedit.cpp:2183
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
void setForeground(const QBrush &brush)
Sets the foreground brush to the specified brush.
Definition: qtextformat.h:350

◆ setTextCursor()

void QTextEdit::setTextCursor ( const QTextCursor cursor)

Sets the visible cursor.

Definition at line 813 of file qtextedit.cpp.

Referenced by keyReleaseEvent(), QAccessibleTextEdit::pasteText(), and QAccessibleTextEdit::setTextCursor().

814 {
815  Q_D(QTextEdit);
816  d->control->setTextCursor(cursor);
817 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ setTextInteractionFlags()

void QTextEdit::setTextInteractionFlags ( Qt::TextInteractionFlags  flags)

Definition at line 2163 of file qtextedit.cpp.

2164 {
2165  Q_D(QTextEdit);
2166  d->control->setTextInteractionFlags(flags);
2167 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ setUndoRedoEnabled()

void QTextEdit::setUndoRedoEnabled ( bool  enable)
inline

Definition at line 175 of file qtextedit.h.

176  { document()->setUndoRedoEnabled(enable); }
QTextDocument * document() const
Returns a pointer to the underlying document.
Definition: qtextedit.cpp:804
void setUndoRedoEnabled(bool enable)

◆ setWordWrapMode()

void QTextEdit::setWordWrapMode ( QTextOption::WrapMode  policy)

Definition at line 2504 of file qtextedit.cpp.

2505 {
2506  Q_D(QTextEdit);
2507  if (mode == d->wordWrap)
2508  return;
2509  d->wordWrap = mode;
2510  d->updateDefaultTextOption();
2511 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ showEvent()

void QTextEdit::showEvent ( QShowEvent )
protectedvirtual

Reimplemented Function

Reimplemented from QWidget.

Definition at line 1767 of file qtextedit.cpp.

1768 {
1769  Q_D(QTextEdit);
1770  if (!d->anchorToScrollToWhenVisible.isEmpty()) {
1771  scrollToAnchor(d->anchorToScrollToWhenVisible);
1772  d->anchorToScrollToWhenVisible.clear();
1773  d->showCursorOnInitialShow = false;
1774  } else if (d->showCursorOnInitialShow) {
1775  d->showCursorOnInitialShow = false;
1777  }
1778 }
double d
Definition: qnumeric_p.h:62
void ensureCursorVisible()
Ensures that the cursor is visible by scrolling the text edit if necessary.
Definition: qtextedit.cpp:2743
#define Q_D(Class)
Definition: qglobal.h:2482
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 ...
Definition: qtextedit.cpp:2277
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ tabChangesFocus()

bool QTextEdit::tabChangesFocus ( ) const

Referenced by print().

◆ tabStopWidth()

int QTextEdit::tabStopWidth ( ) const

Referenced by setOverwriteMode().

◆ textBackgroundColor()

QColor QTextEdit::textBackgroundColor ( ) const

Returns the text background color of the current format.

Since
4.4
See also
setTextBackgroundColor()

Definition at line 736 of file qtextedit.cpp.

737 {
738  Q_D(const QTextEdit);
739  return d->control->textCursor().charFormat().background().color();
740 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ textChanged

void QTextEdit::textChanged ( )
signal

This signal is emitted whenever the document's content changes; for example, when text is inserted or deleted, or when formatting is applied.

◆ textColor()

QColor QTextEdit::textColor ( ) const

Returns the text color of the current format.

See also
setTextColor()

Definition at line 720 of file qtextedit.cpp.

721 {
722  Q_D(const QTextEdit);
723  return d->control->textCursor().charFormat().foreground().color();
724 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ textCursor()

QTextCursor QTextEdit::textCursor ( ) const

Returns a copy of the QTextCursor that represents the currently visible cursor.

Note that changes on the returned cursor do not affect QTextEdit's cursor; use setTextCursor() to update the visible cursor.

Definition at line 824 of file qtextedit.cpp.

Referenced by QAccessibleTextEdit::invokeMethodEx(), QAccessibleTextEdit::pasteText(), and QAccessibleTextEdit::textCursor().

825 {
826  Q_D(const QTextEdit);
827  return d->control->textCursor();
828 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ textInteractionFlags()

Qt::TextInteractionFlags QTextEdit::textInteractionFlags ( ) const

Referenced by setTextInteractionFlags().

◆ timerEvent()

void QTextEdit::timerEvent ( QTimerEvent e)
protectedvirtual
Warning
This function is not part of the public interface.

Reimplemented from QObject.

Definition at line 1102 of file qtextedit.cpp.

1103 {
1104  Q_D(QTextEdit);
1105  if (e->timerId() == d->autoScrollTimer.timerId()) {
1106  QRect visible = d->viewport->rect();
1107  QPoint pos;
1108  if (d->inDrag) {
1109  pos = d->autoScrollDragPos;
1110  visible.adjust(qMin(visible.width()/3,20), qMin(visible.height()/3,20),
1111  -qMin(visible.width()/3,20), -qMin(visible.height()/3,20));
1112  } else {
1113  const QPoint globalPos = QCursor::pos();
1114  pos = d->viewport->mapFromGlobal(globalPos);
1116  mouseMoveEvent(&ev);
1117  }
1118  int deltaY = qMax(pos.y() - visible.top(), visible.bottom() - pos.y()) - visible.height();
1119  int deltaX = qMax(pos.x() - visible.left(), visible.right() - pos.x()) - visible.width();
1120  int delta = qMax(deltaX, deltaY);
1121  if (delta >= 0) {
1122  if (delta < 7)
1123  delta = 7;
1124  int timeout = 4900 / (delta * delta);
1125  d->autoScrollTimer.start(timeout, this);
1126 
1127  if (deltaY > 0)
1128  d->vbar->triggerAction(pos.y() < visible.center().y() ?
1131  if (deltaX > 0)
1132  d->hbar->triggerAction(pos.x() < visible.center().x() ?
1135  }
1136  }
1137 #ifdef QT_KEYPAD_NAVIGATION
1138  else if (e->timerId() == d->deleteAllTimer.timerId()) {
1139  d->deleteAllTimer.stop();
1140  clear();
1141  }
1142 #endif
1143 }
QPoint pos() const
double d
Definition: qnumeric_p.h:62
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
#define Q_D(Class)
Definition: qglobal.h:2482
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
virtual void mouseMoveEvent(QMouseEvent *e)
Reimplemented Function
Definition: qtextedit.cpp:1587
bool visible
whether the widget is visible
Definition: qwidget.h:191
void clear()
Deletes all the text in the text edit.
Definition: qtextedit.cpp:1050
void adjust(int x1, int y1, int x2, int y2)
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
Definition: qrect.h:434
int timerId() const
Returns the unique timer identifier, which is the same identifier as returned from QObject::startTime...
Definition: qcoreevent.h:346
The QMouseEvent class contains parameters that describe a mouse event.
Definition: qevent.h:85
QPoint center() const
Returns the center point of the rectangle.
Definition: qrect.h:300
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70
static QPoint pos()
Returns the position of the cursor (hot spot) in global screen coordinates.
Definition: qcursor_mac.mm:310

◆ toHtml()

QString QTextEdit::toHtml ( ) const
inline

Definition at line 192 of file qtextedit.h.

193  { return document()->toHtml(); }
QTextDocument * document() const
Returns a pointer to the underlying document.
Definition: qtextedit.cpp:804
QString toHtml(const QByteArray &encoding=QByteArray()) const
Returns a string containing an HTML representation of the document.

◆ toPlainText()

QString QTextEdit::toPlainText ( ) const
inline

Returns the text of the text edit as plain text.

See also
QTextEdit::setPlainText()

Definition at line 189 of file qtextedit.h.

Referenced by QMessageBoxDetailsText::text(), and QAccessibleTextEdit::text().

190  { return document()->toPlainText(); }
QString toPlainText() const
Returns the plain text contained in the document.
QTextDocument * document() const
Returns a pointer to the underlying document.
Definition: qtextedit.cpp:804

◆ undo

void QTextEdit::undo ( )
slot

Undoes the last operation.

Use the non-const overload instead.

Since
4.2

If there is no operation to undo, i.e. there is no undo step in the undo/redo history, nothing happens.

See also
redo()

Definition at line 956 of file qtextedit.cpp.

957 {
958  Q_D(QTextEdit);
959  d->control->undo();
960 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ undoAvailable

void QTextEdit::undoAvailable ( bool  b)
signal

This signal is emitted whenever undo operations become available (available is true) or unavailable (available is false).

◆ wheelEvent()

void QTextEdit::wheelEvent ( QWheelEvent e)
protectedvirtual

Reimplemented Function

Reimplemented from QAbstractScrollArea.

Definition at line 1806 of file qtextedit.cpp.

1807 {
1808  Q_D(QTextEdit);
1809  if (!(d->control->textInteractionFlags() & Qt::TextEditable)) {
1810  if (e->modifiers() & Qt::ControlModifier) {
1811  const int delta = e->delta();
1812  if (delta < 0)
1813  zoomOut();
1814  else if (delta > 0)
1815  zoomIn();
1816  return;
1817  }
1818  }
1820  updateMicroFocus();
1821 }
double d
Definition: qnumeric_p.h:62
void zoomIn(int range=1)
Zooms in on the text by making the base font size range points larger and recalculating all font size...
Definition: qtextedit.cpp:2307
#define Q_D(Class)
Definition: qglobal.h:2482
void wheelEvent(QWheelEvent *)
This event handler can be reimplemented in a subclass to receive wheel events for the viewport() widg...
int delta() const
Returns the distance that the wheel is rotated, in eighths of a degree.
Definition: qevent.h:150
void updateMicroFocus()
Updates the widget&#39;s micro focus.
Definition: qwidget.cpp:11820
void zoomOut(int range=1)
Zooms out on the text by making the base font size range points smaller and recalculating all font si...
Definition: qtextedit.cpp:2331
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately before the event occurred.
Definition: qevent.h:79
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ wordWrapMode()

QTextOption::WrapMode QTextEdit::wordWrapMode ( ) const

the mode QTextEdit will use when wrapping text by words

By default, this property is set to QTextOption::WrapAtWordBoundaryOrAnywhere.

See also
QTextOption::WrapMode

Definition at line 2498 of file qtextedit.cpp.

2499 {
2500  Q_D(const QTextEdit);
2501  return d->wordWrap;
2502 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70

◆ zoomIn

void QTextEdit::zoomIn ( int  range = 1)
slot

Zooms in on the text by making the base font size range points larger and recalculating all font sizes to be the new size.

This does not change the size of any images.

See also
zoomOut()

Definition at line 2307 of file qtextedit.cpp.

Referenced by wheelEvent(), and zoomOut().

2308 {
2309  QFont f = font();
2310  const int newSize = f.pointSize() + range;
2311  if (newSize <= 0)
2312  return;
2313  f.setPointSize(newSize);
2314  setFont(f);
2315 }
void setPointSize(int)
Sets the point size to pointSize.
Definition: qfont.cpp:1099
void setFont(const QFont &)
Use the single-argument overload instead.
Definition: qwidget.cpp:4996
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
int pointSize() const
Returns the point size of the font.
Definition: qfont.cpp:981
const QFont & font() const

◆ zoomOut

void QTextEdit::zoomOut ( int  range = 1)
slot

Zooms out on the text by making the base font size range points smaller and recalculating all font sizes to be the new size.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

This does not change the size of any images.

See also
zoomIn()

Definition at line 2331 of file qtextedit.cpp.

Referenced by wheelEvent().

2332 {
2333  zoomIn(-range);
2334 }
void zoomIn(int range=1)
Zooms in on the text by making the base font size range points larger and recalculating all font size...
Definition: qtextedit.cpp:2307

Friends and Related Functions

◆ QTextControl

friend class QTextControl
friend

Definition at line 419 of file qtextedit.h.

◆ QTextDocument

friend class QTextDocument
friend

Definition at line 418 of file qtextedit.h.

◆ QTextEditControl

friend class QTextEditControl
friend

Definition at line 417 of file qtextedit.h.

Properties

◆ acceptRichText

bool QTextEdit::acceptRichText
private

whether the text edit accepts rich text insertions by the user

Since
4.1

When this propery is set to false text edit will accept only plain text input from the user. For example through clipboard or drag and drop.

This property's default is true.

Definition at line 90 of file qtextedit.h.

◆ autoFormatting

QTextEdit::AutoFormatting QTextEdit::autoFormatting
private

the enabled set of auto formatting features

The value can be any combination of the values in the AutoFormattingFlag enum. The default is AutoNone. Choose AutoAll to enable all automatic formatting.

Currently, the only automatic formatting feature provided is AutoBulletList; future versions of Qt may offer more.

Definition at line 76 of file qtextedit.h.

◆ cursorWidth

int QTextEdit::cursorWidth
private

This property specifies the width of the cursor in pixels.

Since
4.2

The default value is 1.

Definition at line 91 of file qtextedit.h.

◆ documentTitle

QTextEdit::documentTitle
private

the title of the document parsed from the text.

By default, for a newly-created, empty document, this property contains an empty string.

Definition at line 78 of file qtextedit.h.

◆ html

QTextEdit::html
private

This property provides an HTML interface to the text of the text edit.

toHtml() returns the text of the text edit as html.

setHtml() changes the text of the text edit. Any previous text is removed and the undo/redo history is cleared. The input text is interpreted as rich text in html format.

Note
It is the responsibility of the caller to make sure that the text is correctly decoded when a QString containing HTML is created and passed to setHtml().

By default, for a newly-created, empty document, this property contains text to describe an HTML 4.0 document with no body text.

See also
{Supported HTML Subset}, plainText

Definition at line 85 of file qtextedit.h.

◆ lineWrapColumnOrWidth

int QTextEdit::lineWrapColumnOrWidth
private

the position (in pixels or columns depending on the wrap mode) where text will be wrapped

If the wrap mode is FixedPixelWidth, the value is the number of pixels from the left edge of the text edit at which text should be wrapped. If the wrap mode is FixedColumnWidth, the value is the column number (in character columns) from the left edge of the text edit at which text should be wrapped.

By default, this property contains a value of 0.

See also
lineWrapMode

Definition at line 82 of file qtextedit.h.

◆ lineWrapMode

QTextEdit::LineWrapMode QTextEdit::lineWrapMode
private

the line wrap mode

The default mode is WidgetWidth which causes words to be wrapped at the right edge of the text edit. Wrapping occurs at whitespace, keeping whole words intact. If you want wrapping to occur within words use setWordWrapMode(). If you set a wrap mode of FixedPixelWidth or FixedColumnWidth you should also call setLineWrapColumnOrWidth() with the width you want.

See also
lineWrapColumnOrWidth

Definition at line 80 of file qtextedit.h.

◆ overwriteMode

bool QTextEdit::overwriteMode
private

whether text entered by the user will overwrite existing text

Since
4.1

As with many text editors, the text editor widget can be configured to insert or overwrite existing text with new text entered by the user.

If this property is true, existing text is overwritten, character-for-character by new text; otherwise, text is inserted at the cursor position, displacing existing text.

By default, this property is false (new text does not overwrite existing text).

Definition at line 88 of file qtextedit.h.

◆ plainText

QTextEdit::plainText
private

This property gets and sets the text editor's contents as plain text.

Since
4.3

Previous contents are removed and undo/redo history is reset when the property is set.

If the text edit has another content type, it will not be replaced by plain text if you call toPlainText(). The only exception to this is the non-break space, nbsp;, that will be converted into standard space.

By default, for an editor with no contents, this property contains an empty string.

See also
html

Definition at line 87 of file qtextedit.h.

◆ readOnly

QTextEdit::readOnly
private

whether the text edit is read-only

In a read-only text edit the user can only navigate through the text and select text; modifying the text is not possible.

This property's default is false.

Definition at line 83 of file qtextedit.h.

◆ tabChangesFocus

bool QTextEdit::tabChangesFocus
private

whether Tab changes focus or is accepted as input

In some occasions text edits should not allow the user to input tabulators or change indentation using the Tab key, as this breaks the focus chain. The default is false.

Definition at line 77 of file qtextedit.h.

◆ tabStopWidth

int QTextEdit::tabStopWidth
private

the tab stop width in pixels

Since
4.1

By default, this property contains a value of 80 pixels.

Definition at line 89 of file qtextedit.h.

◆ textInteractionFlags

Qt::TextInteractionFlags QTextEdit::textInteractionFlags
private

Specifies how the widget should interact with user input.

Since
4.2

The default value depends on whether the QTextEdit is read-only or editable, and whether it is a QTextBrowser or not.

Definition at line 92 of file qtextedit.h.

◆ undoRedoEnabled

QTextEdit::undoRedoEnabled
private

whether undo and redo are enabled

Users are only able to undo or redo actions if this property is true, and if there is an action that can be undone (or redone).

Definition at line 79 of file qtextedit.h.


The documentation for this class was generated from the following files: