qplaintextedit显示html,QPlainTextEdit Class

Member Function Documentation

QPlainTextEdit::QPlainTextEdit(parent = 0)

Constructs an empty QPlainTextEdit with parent parent.

QPlainTextEdit::QPlainTextEdit(const text, parent = 0)

Constructs a QPlainTextEdit with parent parent. The text edit will display the plain text text.

[virtual]QPlainTextEdit::~QPlainTextEdit()

Destructor.

anchorAt(const pos) const

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

This function was introduced in Qt 4.7.

[slot]void QPlainTextEdit::appendHtml(const html)

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

[slot]void QPlainTextEdit::appendPlainText(const text)

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

See alsoappendHtml().

[protected]blockBoundingGeometry(const block) const

Returns the bounding rectangle of the text block in content coordinates. Translate the rectangle with the contentOffset() to get visual coordinates on the viewport.

[protected]blockBoundingRect(const block) const

Returns the bounding rectangle of the text block in the block's own coordinates.

[signal]void QPlainTextEdit::blockCountChanged(intnewBlockCount)

This signal is emitted whenever the block count changes. The new block count is passed in newBlockCount.

[virtual protected]bool QPlainTextEdit::canInsertFromMimeData(const 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. 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.

bool QPlainTextEdit::canPaste() const

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

[slot]void QPlainTextEdit::centerCursor()

Scrolls the document in order to center the cursor vertically.

[virtual protected]void QPlainTextEdit::changeEvent(e)

Reimplemented from QWidget::changeEvent().

[slot]void QPlainTextEdit::clear()

Deletes all the text in the text edit.

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

See alsocut() and setPlainText().

[protected]contentOffset() const

Returns the content's origin in viewport coordinates.

The origin of the content of a plain text edit is always the top left corner of the first visible text block. The content offset is different from (0,0) when the text has been scrolled horizontally, or when the first visible block has been scrolled partially off the screen, i.e. the visible text does not start with the first line of the first visible block, or when the first visible block is the very first block and the editor displays a margin.

[virtual protected]void QPlainTextEdit::contextMenuEvent(event)

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 MyQPlainTextEdit::contextMenuEvent(*event)

{

*menu = createStandardContextMenu();

menu->addAction(tr("My Menu Item"));

//...

menu->exec(event->globalPos());

delete menu;

}

[slot]void QPlainTextEdit::copy()

Copies any selected text to the clipboard.

[signal]void QPlainTextEdit::copyAvailable(boolyes)

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.

[virtual protected]createMimeDataFromSelection() const

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 copied 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.

createStandardContextMenu()

This function creates the standard context menu which is shown when the user clicks on the line edit with the right mouse button. It is called from the default contextMenuEvent() handler. The popup menu's ownership is transferred to the caller.

currentCharFormat() const

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

cursorForPosition(const pos) const

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

[signal]void QPlainTextEdit::cursorPositionChanged()

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

cursorRect(const cursor) const

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

cursorRect() const

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

[slot]void QPlainTextEdit::cut()

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

If there is no selected text nothing happens.

See alsocopy() and paste().

document() const

Returns a pointer to the underlying document.

See alsosetDocument().

[virtual protected]void QPlainTextEdit::dragEnterEvent(e)

[virtual protected]void QPlainTextEdit::dragLeaveEvent(e)

[virtual protected]void QPlainTextEdit::dragMoveEvent(e)

[virtual protected]void QPlainTextEdit::dropEvent(e)

Reimplemented from QWidget::dropEvent().

void QPlainTextEdit::ensureCursorVisible()

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

extraSelections() const

Returns previously set extra selections.

bool QPlainTextEdit::find(const exp, options = 0)

Finds the next occurrence of the string, exp, using the given options. Returns true if exp was found and changes the cursor to select the match; otherwise returns false.

[protected]firstVisibleBlock() const

Returns the first visible block.

[virtual protected]void QPlainTextEdit::focusInEvent(e)

Reimplemented from QWidget::focusInEvent().

[virtual protected]bool QPlainTextEdit::focusNextPrevChild(boolnext)

[virtual protected]void QPlainTextEdit::focusOutEvent(e)

[protected]getPaintContext() const

Returns the paint context for the viewport(), useful only when reimplementing paintEvent().

[virtual protected]void QPlainTextEdit::inputMethodEvent(e)

[virtual protected]inputMethodQuery(Qt::InputMethodQueryproperty) const

[virtual protected]void QPlainTextEdit::insertFromMimeData(const source)

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.

[slot]void QPlainTextEdit::insertPlainText(const text)

Convenience slot that inserts text at the current cursor position.

It is equivalent to

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

[virtual protected]void QPlainTextEdit::keyPressEvent(e)

[virtual protected]void QPlainTextEdit::keyReleaseEvent(e)

[virtual]loadResource(inttype, const name)

Loads the resource specified by the given type and name.

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

void QPlainTextEdit::mergeCurrentCharFormat(const 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.

[signal]void QPlainTextEdit::modificationChanged(boolchanged)

This signal is emitted whenever the content of the document changes in a way that affects the modification state. If changed is true, the document has been modified; otherwise it is false.

For example, calling setModified(false) on a document and then inserting text causes the signal to get emitted. If you undo that operation, causing the document to return to its original unmodified state, the signal will get emitted again.

[virtual protected]void QPlainTextEdit::mouseDoubleClickEvent(e)

[virtual protected]void QPlainTextEdit::mouseMoveEvent(e)

[virtual protected]void QPlainTextEdit::mousePressEvent(e)

[virtual protected]void QPlainTextEdit::mouseReleaseEvent(e)

void QPlainTextEdit::moveCursor(operation, mode = QTextCursor::MoveAnchor)

Moves the cursor by performing the given operation.

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.

[virtual protected]void QPlainTextEdit::paintEvent(e)

Reimplemented from QWidget::paintEvent().

[slot]void QPlainTextEdit::paste()

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 QPlainTextEdit can paste and how it is being pasted, reimplement the virtual canInsertFromMimeData() and insertFromMimeData() functions.

See alsocut() and copy().

void QPlainTextEdit::print(printer) const

Convenience function to print the text edit's document to the given printer. This is equivalent to calling the print method on the document directly except that this function also supports QPrinter::Selection as print range.

[slot]void QPlainTextEdit::redo()

Redoes the last operation.

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

See alsoundo().

[signal]void QPlainTextEdit::redoAvailable(boolavailable)

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

[virtual protected]void QPlainTextEdit::resizeEvent(e)

Reimplemented from QWidget::resizeEvent().

[virtual protected]void QPlainTextEdit::scrollContentsBy(intdx, intdy)

[slot]void QPlainTextEdit::selectAll()

Selects all text.

See alsocopy(), cut(), and textCursor().

[signal]void QPlainTextEdit::selectionChanged()

This signal is emitted whenever the selection changes.

void QPlainTextEdit::setCurrentCharFormat(const 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.

void QPlainTextEdit::setDocument(document)

Makes document the new document of the text editor.

The parent QObject of the provided document remains the owner of the object. If the current document is a child of the text editor, then it is deleted.

The document must have a document layout that inherits QPlainTextDocumentLayout (see QTextDocument::setDocumentLayout()).

See alsodocument().

void QPlainTextEdit::setExtraSelections(const selections)

This function allows temporarily marking certain regions in the document with a given color, specified as selections. 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.

void QPlainTextEdit::setTextCursor(const cursor)

Sets the visible cursor.

See alsotextCursor().

[virtual protected]void QPlainTextEdit::showEvent(

Reimplemented from QWidget::showEvent().

textCursor() const

Returns a copy of the QTextCursor that represents the currently visible cursor. Note that changes on the returned cursor do not affect QPlainTextEdit's cursor; use setTextCursor() to update the visible cursor.

[slot]void QPlainTextEdit::undo()

Undoes the last operation.

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

See alsoredo().

[signal]void QPlainTextEdit::undoAvailable(boolavailable)

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

[signal]void QPlainTextEdit::updateRequest(const rect, intdy)

This signal is emitted when the text document needs an update of the specified rect. If the text is scrolled, rect will cover the entire viewport area. If the text is scrolled vertically, dy carries the amount of pixels the viewport was scrolled.

The purpose of the signal is to support extra widgets in plain text edit subclasses that e.g. show line numbers, breakpoints, or other extra information.

[virtual protected]void QPlainTextEdit::wheelEvent(e)

Reimplemented from QWidget::wheelEvent().

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值