<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # QTextCursor Class Reference ## [[QtGui](index.htm) module] 該QTextCursor類提供了一個API來訪問和修改QTextDocuments 。[More...](#details) ### Types * `enum MoveMode { MoveAnchor, KeepAnchor }` * `enum MoveOperation { NoMove, Start, Up, StartOfLine, ..., PreviousRow }` * `enum SelectionType { WordUnderCursor, LineUnderCursor, BlockUnderCursor, Document }` ### Methods * `__init__ (self)` * `__init__ (self, QTextDocument?document)` * `__init__ (self, QTextFrame?frame)` * `__init__ (self, QTextBlock?block)` * `__init__ (self, QTextCursor?cursor)` * `int anchor (self)` * `bool atBlockEnd (self)` * `bool atBlockStart (self)` * `bool atEnd (self)` * `bool atStart (self)` * `beginEditBlock (self)` * `QTextBlock block (self)` * `QTextCharFormat blockCharFormat (self)` * `QTextBlockFormat blockFormat (self)` * `int blockNumber (self)` * `QTextCharFormat charFormat (self)` * `clearSelection (self)` * `int columnNumber (self)` * `QTextList createList (self, QTextListFormat?format)` * `QTextList createList (self, QTextListFormat.Style?style)` * `QTextFrame currentFrame (self)` * `QTextList currentList (self)` * `QTextTable currentTable (self)` * `deleteChar (self)` * `deletePreviousChar (self)` * `QTextDocument document (self)` * `endEditBlock (self)` * `bool hasComplexSelection (self)` * `bool hasSelection (self)` * `insertBlock (self)` * `insertBlock (self, QTextBlockFormat?format)` * `insertBlock (self, QTextBlockFormat?format, QTextCharFormat?charFormat)` * `insertFragment (self, QTextDocumentFragment?fragment)` * `QTextFrame insertFrame (self, QTextFrameFormat?format)` * `insertHtml (self, QString?html)` * `insertImage (self, QTextImageFormat?format)` * `insertImage (self, QTextImageFormat?format, QTextFrameFormat.Position?alignment)` * `insertImage (self, QString?name)` * `insertImage (self, QImage?image, QString?name?=?QString())` * `QTextList insertList (self, QTextListFormat?format)` * `QTextList insertList (self, QTextListFormat.Style?style)` * `QTextTable insertTable (self, int?rows, int?cols, QTextTableFormat?format)` * `QTextTable insertTable (self, int?rows, int?cols)` * `insertText (self, QString?text)` * `insertText (self, QString?text, QTextCharFormat?format)` * `bool isCopyOf (self, QTextCursor?other)` * `bool isNull (self)` * `joinPreviousEditBlock (self)` * `bool keepPositionOnInsert (self)` * `mergeBlockCharFormat (self, QTextCharFormat?modifier)` * `mergeBlockFormat (self, QTextBlockFormat?modifier)` * `mergeCharFormat (self, QTextCharFormat?modifier)` * `bool movePosition (self, MoveOperation?op, MoveMode?mode?=?QTextCursor.MoveAnchor, int?n?=?1)` * `int position (self)` * `int positionInBlock (self)` * `removeSelectedText (self)` * `select (self, SelectionType?selection)` * `(int?firstRow, int?numRows, int?firstColumn, int?numColumns) selectedTableCells (self)` * `QString selectedText (self)` * `QTextDocumentFragment selection (self)` * `int selectionEnd (self)` * `int selectionStart (self)` * `setBlockCharFormat (self, QTextCharFormat?format)` * `setBlockFormat (self, QTextBlockFormat?format)` * `setCharFormat (self, QTextCharFormat?format)` * `setKeepPositionOnInsert (self, bool?b)` * `setPosition (self, int?pos, MoveMode?mode?=?QTextCursor.MoveAnchor)` * `setVerticalMovementX (self, int?x)` * `setVisualNavigation (self, bool?b)` * `int verticalMovementX (self)` * `bool visualNavigation (self)` ### Special Methods * `bool __eq__ (self, QTextCursor?rhs)` * `bool __ge__ (self, QTextCursor?rhs)` * `bool __gt__ (self, QTextCursor?rhs)` * `bool __le__ (self, QTextCursor?rhs)` * `bool __lt__ (self, QTextCursor?rhs)` * `bool __ne__ (self, QTextCursor?rhs)` * * * ## Detailed Description 該QTextCursor類提供了一個API來訪問和修改QTextDocuments 。 文字游標是用來通過模仿光標在文本編輯器的行為的編程接口來訪問和修改的內容及相關文本文檔的結構對象。 QTextCursor包含內兩個光標的位置信息[QTextDocument](qtextdocument.html)而任何選擇,它已經做。 QTextCursor是仿照文本光標的行為在文本編輯器的方式,通過提供用戶界面執行標準操作的編程方法。一個文檔可以被看作是字符的字符串。光標的當前[position](qtextcursor.html#position)( )則始終為_between_兩個連續字符的字符串,否則_before_的第一個字符或_after_在最后一個字符的字符串。文件還可以包含表格,列表,圖像和其他對象除了文字,但是,從開發者的角度來看,該文件可以被視為一個長字符串。該串中的某些部分可以被認為在于特定塊(例如段落)中,或一個表的單元格或列表的項目,或其它結構元件內。當我們提到“當前字符”我們立即指的是字符_before_光標[position](qtextcursor.html#position)( )在文檔中。同樣,“當前塊”是一個包含光標塊[position](qtextcursor.html#position)( ) 。 一個QTextCursor也有一個[anchor](qtextcursor.html#anchor)()位置。這是之間的文本[anchor](qtextcursor.html#anchor)( )和[position](qtextcursor.html#position)()是該選擇。如果[anchor](qtextcursor.html#anchor)()==[position](qtextcursor.html#position)( )沒有選擇。 光標位置可以通過編程方式使用改變[setPosition](qtextcursor.html#setPosition)()和[movePosition](qtextcursor.html#movePosition)() ,后者也可以被用來選擇文本。對于選擇看[selectionStart](qtextcursor.html#selectionStart)( )[selectionEnd](qtextcursor.html#selectionEnd)( )[hasSelection](qtextcursor.html#hasSelection)( )[clearSelection](qtextcursor.html#clearSelection)()和[removeSelectedText](qtextcursor.html#removeSelectedText)( ) 。 如果[position](qtextcursor.html#position)()是在一個塊的開始[atBlockStart](qtextcursor.html#atBlockStart)( )返回True ,如果它是在一個塊結束[atBlockEnd](qtextcursor.html#atBlockEnd)( )返回True 。當前字符的格式由返回[charFormat](qtextcursor.html#charFormat)()和當前塊的格式是由返回[blockFormat](qtextcursor.html#blockFormat)( ) 。 格式化可以使用適用于當前文本文檔[setCharFormat](qtextcursor.html#setCharFormat)( )[mergeCharFormat](qtextcursor.html#mergeCharFormat)( )[setBlockFormat](qtextcursor.html#setBlockFormat)()和[mergeBlockFormat](qtextcursor.html#mergeBlockFormat)()函數。在'設置'功能將取代光標的當前字符或塊格式,而“合并”功能添加給定的格式屬性光標的當前格式。如果光標有一個選擇給定的格式應用到當前的選擇。請注意,當被選擇的塊的唯一部件的塊格式被應用到整個塊。在當前字符位置的文本可以使用變成一個列表[createList](qtextcursor.html#createList)( ) 。 缺失可以使用可以實現[deleteChar](qtextcursor.html#deleteChar)( )[deletePreviousChar](qtextcursor.html#deletePreviousChar)()和[removeSelectedText](qtextcursor.html#removeSelectedText)( ) 。 文本串可以被插入到與該文件[insertText](qtextcursor.html#insertText)()函數,塊(即新段落)可以插入與[insertBlock](qtextcursor.html#insertBlock)( ) 。 現有的文本片段可被插入與[insertFragment](qtextcursor.html#insertFragment)( ),但是,如果你要插入文本塊的各種格式,通常還是更容易使用[insertText](qtextcursor.html#insertText)() ,并提供一個字符的格式。 各種類型的較高級別的結構中,也可以插入到光標的文件: * Lists are ordered sequences of block elements that are decorated with bullet points or symbols. These are inserted in a specified format with [insertList](qtextcursor.html#insertList)(). * Tables are inserted with the [insertTable](qtextcursor.html#insertTable)() function, and can be given an optional format. These contain an array of cells that can be traversed using the cursor. * Inline images are inserted with [insertImage](qtextcursor.html#insertImage)(). The image to be used can be specified in an image format, or by name. * Frames are inserted by calling [insertFrame](qtextcursor.html#insertFrame)() with a specified format. 操作可以分組(即視作撤銷/重做一個動作)使用[beginEditBlock](qtextcursor.html#beginEditBlock)()和[endEditBlock](qtextcursor.html#endEditBlock)( ) 。 光標移動僅限于有效的光標位置。在拉丁語寫作,這是任何兩個連續字符的文本之間,第一個字符之前,或之后的最后一個字符。在其他一些書寫系統的光標移動僅限于“集群” (如一個音節在梵文,或基字母加變音符號) 。功能,如[movePosition](qtextcursor.html#movePosition)()和[deleteChar](qtextcursor.html#deleteChar)( )限制光標移動到這些有效的位置。 * * * ## Type Documentation ``` QTextCursor.MoveMode ``` | Constant | Value | Description | | --- | --- | --- | | `QTextCursor.MoveAnchor` | `0` | 移動錨定至相同的位置的光標本身。 | | `QTextCursor.KeepAnchor` | `1` | 保持錨在哪里。 | 如果[anchor](qtextcursor.html#anchor)()被保持在那里它是與[position](qtextcursor.html#position)( )移動,在之間的文本將被選中。 ``` QTextCursor.MoveOperation ``` | Constant | Value | Description | | --- | --- | --- | | `QTextCursor.NoMove` | `0` | 保持光標的地方是 | | `QTextCursor.Start` | `1` | 移動到文檔的開始。 | | `QTextCursor.StartOfLine` | `3` | 移動到當前行的開始。 | | `QTextCursor.StartOfBlock` | `4` | 移動到當前塊的開始。 | | `QTextCursor.StartOfWord` | `5` | 移動到當前單詞的開頭。 | | `QTextCursor.PreviousBlock` | `6` | 移動到前一個塊的開始。 | | `QTextCursor.PreviousCharacter` | `7` | 移動到前一個字符。 | | `QTextCursor.PreviousWord` | `8` | 移動到前一個單詞的起始處。 | | `QTextCursor.Up` | `2` | 向上移動一行。 | | `QTextCursor.Left` | `9` | 向左移動一個字符。 | | `QTextCursor.WordLeft` | `10` | 向左移動一個詞。 | | `QTextCursor.End` | `11` | 移動到文檔的末尾。 | | `QTextCursor.EndOfLine` | `13` | 移動到當前行的結尾。 | | `QTextCursor.EndOfWord` | `14` | 移動到當前字的結尾。 | | `QTextCursor.EndOfBlock` | `15` | 移動到當前塊的結尾。 | | `QTextCursor.NextBlock` | `16` | 移動到下一個塊的開始。 | | `QTextCursor.NextCharacter` | `17` | 移動到下一個字符。 | | `QTextCursor.NextWord` | `18` | 移動到下一個單詞。 | | `QTextCursor.Down` | `12` | 向下移動一行。 | | `QTextCursor.Right` | `19` | 向右移動一個字符。 | | `QTextCursor.WordRight` | `20` | 向右移動一個詞。 | | `QTextCursor.NextCell` | `21` | 移動到下一個表格單元格的開頭當前表內。如果當前單元格是行中的最后一個單元格,將光標移動到下一行的第一個單元格。 | | `QTextCursor.PreviousCell` | `22` | 移動到前一個表格單元格的開頭當前表內。如果當前單元格是行中的第一個單元格,將光標移動到前一行的最后一個單元格。 | | `QTextCursor.NextRow` | `23` | 移動到下一行的當前表中的第一個新小區。 | | `QTextCursor.PreviousRow` | `24` | 移動到上一行在當前表中的最后一個單元格。 | **See also** [movePosition](qtextcursor.html#movePosition)( ) 。 ``` QTextCursor.SelectionType ``` 該枚舉描述可以與應用于所選內容的類型[select](qtextcursor.html#select)()函數。 | Constant | Value | Description | | --- | --- | --- | | `QTextCursor.Document` | `3` | 選擇整個文檔。 | | `QTextCursor.BlockUnderCursor` | `2` | 選擇光標下的文本塊。 | | `QTextCursor.LineUnderCursor` | `1` | 選擇光標下的文本行。 | | `QTextCursor.WordUnderCursor` | `0` | 選擇光標下的單詞。如果游標未定位的可選字符的字符串中,沒有文本被選中。 | * * * ## Method Documentation ``` QTextCursor.__init__ (self) ``` 構造一個空指針。 ``` QTextCursor.__init__ (self, QTextDocument?document) ``` 構造一個游標指向的開始_document_。 ``` QTextCursor.__init__ (self, QTextFrame?frame) ``` ``` QTextCursor.__init__ (self, QTextBlock?block) ``` 構造一個游標指向的開始_frame_。 ``` QTextCursor.__init__ (self, QTextCursor?cursor) ``` 構造一個游標指向的開始_block_。 ``` int QTextCursor.anchor (self) ``` 返回的錨定位置,這是相同的[position](qtextcursor.html#position)() ,除非在此情況下,選擇[position](qtextcursor.html#position)()標記的選擇和錨的一端()馬克的另一端。就像光標位置,支撐點位是字符之間。 **See also** [position](qtextcursor.html#position)( )[setPosition](qtextcursor.html#setPosition)( )[movePosition](qtextcursor.html#movePosition)( )[selectionStart](qtextcursor.html#selectionStart)()和[selectionEnd](qtextcursor.html#selectionEnd)( ) 。 ``` bool QTextCursor.atBlockEnd (self) ``` 返回True如果光標在一個塊結束,否則返回False 。 **See also** [atBlockStart](qtextcursor.html#atBlockStart)()和[atEnd](qtextcursor.html#atEnd)( ) 。 ``` bool QTextCursor.atBlockStart (self) ``` 返回True如果光標在一個塊的開始,否則返回False 。 **See also** [atBlockEnd](qtextcursor.html#atBlockEnd)()和[atStart](qtextcursor.html#atStart)( ) 。 ``` bool QTextCursor.atEnd (self) ``` 返回True如果光標在文檔的末尾,否則返回False 。 此功能被引入Qt的4.6 。 **See also** [atStart](qtextcursor.html#atStart)()和[atBlockEnd](qtextcursor.html#atBlockEnd)( ) 。 ``` bool QTextCursor.atStart (self) ``` 返回True如果光標在文件的開頭,否則返回False 。 **See also** [atBlockStart](qtextcursor.html#atBlockStart)()和[atEnd](qtextcursor.html#atEnd)( ) 。 ``` QTextCursor.beginEditBlock (self) ``` 表示編輯操作上應顯示為一個單一的操作從視圖中撤消/重做點的文件塊的開始。 例如: ``` [QTextCursor](qtextcursor.html) cursor(textDocument); cursor.beginEditBlock(); cursor.insertText("Hello"); cursor.insertText("World"); cursor.endEditBlock(); textDocument->undo(); ``` 撤消()的調用會導致兩個插入到被撤消,造成兩個“世界”和“你好”被刪除。 它也可以嵌套調用beginEditBlock和endEditBlock 。最上面的一對將決定撤消/重做操作的范圍。 **See also** [endEditBlock](qtextcursor.html#endEditBlock)( ) 。 ``` QTextBlock QTextCursor.block (self) ``` [ 返回包含光標塊。 ](qtextblock.html) ``` QTextCharFormat QTextCursor.blockCharFormat (self) ``` [ 返回光標所在的塊的塊的字符格式 塊char格式是一個空塊的開頭插入文本時所使用的格式。 ](qtextcharformat.html) [**See also**](qtextcharformat.html) [setBlockCharFormat](qtextcursor.html#setBlockCharFormat)( ) 。 ``` QTextBlockFormat QTextCursor.blockFormat (self) ``` [ 返回光標所在的塊的塊格式 ](qtextblockformat.html) [**See also**](qtextblockformat.html) [setBlockFormat](qtextcursor.html#setBlockFormat)()和[charFormat](qtextcursor.html#charFormat)( ) 。 ``` int QTextCursor.blockNumber (self) ``` 返回光標在,或0,如果光標是無效的塊的數目。 請注意,此功能才有意義的文件而無需復雜的對象,如表格或框架。 這個函數中引入了Qt 4.2中。 ``` QTextCharFormat QTextCursor.charFormat (self) ``` [](qtextcharformat.html) [立即光標前返回字符的格式](qtextcharformat.html)[position](qtextcursor.html#position)( ) 。如果光標被定位在一個文本塊,它是不是空的開頭,然后該字符的光標之后的格式被返回。 **See also** [setCharFormat](qtextcursor.html#setCharFormat)( )[insertText](qtextcursor.html#insertText)()和[blockFormat](qtextcursor.html#blockFormat)( ) 。 ``` QTextCursor.clearSelection (self) ``` 通過錨設置到光標位置清除當前的選擇。 需要注意的是它**not**刪除選定的文本。 **See also** [removeSelectedText](qtextcursor.html#removeSelectedText)()和[hasSelection](qtextcursor.html#hasSelection)( ) 。 ``` int QTextCursor.columnNumber (self) ``` 返回其包含的行內光標的位置。 注意,這是列數相對于一個纏繞線,而不是相對于該塊(即段落)。 你可能想打電話[positionInBlock](qtextcursor.html#positionInBlock)( )來代替。 這個函數中引入了Qt 4.2中。 **See also** [positionInBlock](qtextcursor.html#positionInBlock)( ) 。 ``` QTextList QTextCursor.createList (self, QTextListFormat?format) ``` [ 創建并返回一個新的列表給定的_format_,并使得當前段落光標在第一個列表項。 ](qtextlist.html) [**See also**](qtextlist.html) [insertList](qtextcursor.html#insertList)()和[currentList](qtextcursor.html#currentList)( ) 。 ``` QTextList QTextCursor.createList (self, QTextListFormat.Style?style) ``` [ 這是一個重載函數。 創建并返回一個新的列表給定的_style_,使得光標的當前段落的第一個列表項。 ](qtextlist.html) [要使用的樣式被定義](qtextlist.html)[QTextListFormat.Style](qtextlistformat.html#Style-enum)枚舉。 **See also** [insertList](qtextcursor.html#insertList)()和[currentList](qtextcursor.html#currentList)( ) 。 ``` QTextFrame QTextCursor.currentFrame (self) ``` [ 將指針返回到當前幀。返回0,如果游標是無效的。 ](qtextframe.html) [**See also**](qtextframe.html) [insertFrame](qtextcursor.html#insertFrame)( ) 。 ``` QTextList QTextCursor.currentList (self) ``` [](qtextlist.html) [返回當前列表中,如果光標](qtextlist.html)[position](qtextcursor.html#position)( )是一個塊是列表的一部分里面,否則返回0 。 **See also** [insertList](qtextcursor.html#insertList)()和[createList](qtextcursor.html#createList)( ) 。 ``` QTextTable QTextCursor.currentTable (self) ``` [](qtexttable.html) [返回一個指針,指向當前表如果光標](qtexttable.html)[position](qtextcursor.html#position)()是一個塊,它是一個表中的部分內,否則返回0 。 **See also** [insertTable](qtextcursor.html#insertTable)( ) 。 ``` QTextCursor.deleteChar (self) ``` 如果沒有選定的文本,刪除字符_at_當前光標位置,否則將刪除選定的文本。 **See also** [deletePreviousChar](qtextcursor.html#deletePreviousChar)( )[hasSelection](qtextcursor.html#hasSelection)()和[clearSelection](qtextcursor.html#clearSelection)( ) 。 ``` QTextCursor.deletePreviousChar (self) ``` 如果沒有選定的文本,刪除字符_before_當前光標位置,否則將刪除選定的文本。 **See also** [deleteChar](qtextcursor.html#deleteChar)( )[hasSelection](qtextcursor.html#hasSelection)()和[clearSelection](qtextcursor.html#clearSelection)( ) 。 ``` QTextDocument QTextCursor.document (self) ``` [ 返回此光標關聯的文件。 此功能被引入Qt的4.5 。 ``` QTextCursor.endEditBlock (self) ``` 表示編輯操作上應顯示為一個單一的操作從視圖中撤消/重做點的文件塊的結尾。 ](qtextdocument.html) [**See also**](qtextdocument.html) [beginEditBlock](qtextcursor.html#beginEditBlock)( ) 。 ``` bool QTextCursor.hasComplexSelection (self) ``` 如果光標包含一個選擇,是不是只是一個范圍,則返回True[selectionStart](qtextcursor.html#selectionStart)()來[selectionEnd](qtextcursor.html#selectionEnd)( ),否則返回False 。 復雜的選擇是那些跨越至少兩個小區中的表格;他們的程度是通過指定[selectedTableCells](qtextcursor.html#selectedTableCells)( ) 。 ``` bool QTextCursor.hasSelection (self) ``` 返回True如果光標包含一個選擇,否則返回False 。 ``` QTextCursor.insertBlock (self) ``` 在游標位置插入一個新的空塊[position](qtextcursor.html#position)()與當前[blockFormat](qtextcursor.html#blockFormat)()和[charFormat](qtextcursor.html#charFormat)( ) 。 **See also** [setBlockFormat](qtextcursor.html#setBlockFormat)( ) 。 ``` QTextCursor.insertBlock (self, QTextBlockFormat?format) ``` 這是一個重載函數。 在游標位置插入一個新的空塊[position](qtextcursor.html#position)( )與塊格式_format_和電流[charFormat](qtextcursor.html#charFormat)( )為塊字符格式。 **See also** [setBlockFormat](qtextcursor.html#setBlockFormat)( ) 。 ``` QTextCursor.insertBlock (self, QTextBlockFormat?format, QTextCharFormat?charFormat) ``` 這是一個重載函數。 在游標位置插入一個新的空塊[position](qtextcursor.html#position)( )與塊格式_format_和_charFormat_為塊字符格式。 **See also** [setBlockFormat](qtextcursor.html#setBlockFormat)( ) 。 ``` QTextCursor.insertFragment (self, QTextDocumentFragment?fragment) ``` 插入文本_fragment_在當前[position](qtextcursor.html#position)( ) 。 ``` QTextFrame QTextCursor.insertFrame (self, QTextFrameFormat?format) ``` [](qtextframe.html) [插入一個框架給定的_format_在當前光標](qtextframe.html)[position](qtextcursor.html#position)( ) ,移動光標[position](qtextcursor.html#position)()的框架內,并返回該幀。 如果光標持有的選擇,整機選用移動的框架內。 **See also** [hasSelection](qtextcursor.html#hasSelection)( ) 。 ``` QTextCursor.insertHtml (self, QString?html) ``` 插入文本_html_在當前[position](qtextcursor.html#position)( ) 。該文本被解釋為HTML 。 **Note:**使用此功能時使用樣式表,樣式表只適用于文檔中的當前塊。為了對整個文檔應用樣式表,使用[QTextDocument.setDefaultStyleSheet](qtextdocument.html#defaultStyleSheet-prop)( )來代替。 這個函數中引入了Qt 4.2中。 ``` QTextCursor.insertImage (self, QTextImageFormat?format) ``` 插入由所定義的圖像_format_在當前[position](qtextcursor.html#position)( ) 。 ``` QTextCursor.insertImage (self, QTextImageFormat?format, QTextFrameFormat.Position?alignment) ``` 這是一個重載函數。 ,將圖像由給定的定義_format_在光標的當前位置與指定的_alignment_。 這個函數中引入了Qt 4.2中。 **See also** [position](qtextcursor.html#position)( ) 。 ``` QTextCursor.insertImage (self, QString?name) ``` 這是一個重載函數。 便利的方法與給定插入圖像_name_在當前[position](qtextcursor.html#position)( ) 。 ``` [QImage](qimage.html) img = ... textDocument->addResource([QTextDocument](qtextdocument.html).ImageResource, [QUrl](qurl.html)("myimage"), img); cursor.insertImage("myimage"); ``` ``` QTextCursor.insertImage (self, QImage?image, QString?name?=?QString()) ``` 這是一個重載函數。 便利功能用于插入給定的_image_具有可選_name_在當前[position](qtextcursor.html#position)( ) 。 此功能被引入Qt的4.5 。 ``` QTextList QTextCursor.insertList (self, QTextListFormat?format) ``` [ 插入一個新塊的當前位置,并使它成為一個新創建的列表中給出的第一個列表項_format_。返回創建的列表。 ](qtextlist.html) [**See also**](qtextlist.html) [currentList](qtextcursor.html#currentList)( )[createList](qtextcursor.html#createList)()和[insertBlock](qtextcursor.html#insertBlock)( ) 。 ``` QTextList QTextCursor.insertList (self, QTextListFormat.Style?style) ``` [ 這是一個重載函數。 插入一個新塊的當前位置,并使它成為一個新創建的列表中給出的第一個列表項_style_。返回創建的列表。 ](qtextlist.html) [**See also**](qtextlist.html) [currentList](qtextcursor.html#currentList)( )[createList](qtextcursor.html#createList)()和[insertBlock](qtextcursor.html#insertBlock)( ) 。 ``` QTextTable QTextCursor.insertTable (self, int?rows, int?cols, QTextTableFormat?format) ``` [](qtexttable.html) [創建一個具有給定數量的新表_rows_和_columns_在指定的_format_,將其插入到當前光標](qtexttable.html)[position](qtextcursor.html#position)( )在文件中,并返回表對象。將光標移動到第一小區的開頭。 必須有在表中的至少一行和一列。 **See also** [currentTable](qtextcursor.html#currentTable)( ) 。 ``` QTextTable QTextCursor.insertTable (self, int?rows, int?cols) ``` [ 這是一個重載函數。 ](qtexttable.html) [創建一個具有給定數量的新表_rows_和_columns_,將其插入到當前光標](qtexttable.html)[position](qtextcursor.html#position)( )在文件中,并返回表對象。將光標移動到第一小區的開頭。 必須有在表中的至少一行和一列。 **See also** [currentTable](qtextcursor.html#currentTable)( ) 。 ``` QTextCursor.insertText (self, QString?text) ``` Inserts _text_在當前位置,使用當前的字符格式。 如果有選擇,選擇被刪除,取而代之的是_text_例如: ``` cursor.clearSelection(); cursor.movePosition([QTextCursor](qtextcursor.html).NextWord, [QTextCursor](qtextcursor.html).KeepAnchor); cursor.insertText("Hello World"); ``` 這將清除任何現有的選擇,選擇這個詞在光標(即[position](qtextcursor.html#position)( )向前) ,并替換選擇的短語的“Hello World ” 。 在插入的文本任何ASCII換行符( \ n)被轉換成Unicode塊分隔符,對應[insertBlock](qtextcursor.html#insertBlock)( )調用。 **See also** [charFormat](qtextcursor.html#charFormat)()和[hasSelection](qtextcursor.html#hasSelection)( ) 。 ``` QTextCursor.insertText (self, QString?text, QTextCharFormat?format) ``` 這是一個重載函數。 Inserts _text_在當前位置與給定的_format_。 ``` bool QTextCursor.isCopyOf (self, QTextCursor?other) ``` 返回True如果光標和_other_是彼此的副本,即它們中的一個被創建為其它和因為無論已移動的一個副本。這比平等更嚴格的。 **See also** [operator=](qtextcursor.html#operator-eq)()和[operator==](qtextcursor.html#operator-eq-eq)( ) 。 ``` bool QTextCursor.isNull (self) ``` 返回True如果光標為空,否則返回False 。一個空指針被默認構造函數創建的。 ``` QTextCursor.joinPreviousEditBlock (self) ``` 喜歡[beginEditBlock](qtextcursor.html#beginEditBlock)( )表示編輯操作的塊應顯示為撤消/重做一個操作的開始。然而不同[beginEditBlock](qtextcursor.html#beginEditBlock)( )它不會啟動一個新的塊,但反轉以前調用[endEditBlock](qtextcursor.html#endEditBlock)( ),因此使得下面創建的前一個編輯數據塊的操作部分。 例如: ``` [QTextCursor](qtextcursor.html) cursor(textDocument); cursor.beginEditBlock(); cursor.insertText("Hello"); cursor.insertText("World"); cursor.endEditBlock(); ... cursor.joinPreviousEditBlock(); cursor.insertText("Hey"); cursor.endEditBlock(); textDocument->undo(); ``` 撤消()的調用會導致所有三個插入到被撤消。 **See also** [beginEditBlock](qtextcursor.html#beginEditBlock)()和[endEditBlock](qtextcursor.html#endEditBlock)( ) 。 ``` bool QTextCursor.keepPositionOnInsert (self) ``` 返回游標是否應保持其目前的位置,當文本被插入到光標的位置。 默認值為False ; 此功能被引入Qt的4.7 。 **See also** [setKeepPositionOnInsert](qtextcursor.html#setKeepPositionOnInsert)( ) 。 ``` QTextCursor.mergeBlockCharFormat (self, QTextCharFormat?modifier) ``` 修改當前塊的塊char格式(或包含在選區中的所有塊)由指定的程序段格式_modifier_。 **See also** [setBlockCharFormat](qtextcursor.html#setBlockCharFormat)( ) 。 ``` QTextCursor.mergeBlockFormat (self, QTextBlockFormat?modifier) ``` 修改當前塊的塊格式(或包含在選擇的所有塊)與所指定的數據塊格式_modifier_。 **See also** [setBlockFormat](qtextcursor.html#setBlockFormat)()和[blockFormat](qtextcursor.html#blockFormat)( ) 。 ``` QTextCursor.mergeCharFormat (self, QTextCharFormat?modifier) ``` 合并光標的與格式描述的屬性當前字符格式_modifier_。如果光標有一個選擇,這個功能適用于所有設置屬性_modifier_所有的字符格式,是選擇的一部分。 **See also** [hasSelection](qtextcursor.html#hasSelection)()和[setCharFormat](qtextcursor.html#setCharFormat)( ) 。 ``` bool QTextCursor.movePosition (self, MoveOperation?op, MoveMode?mode?=?QTextCursor.MoveAnchor, int?n?=?1) ``` 通過執行給定的移動光標_operation_ _n_次,使用指定的_mode_,并返回True,如果所有操作都成功完成,否則返回False 。 例如,如果這個功能被反復使用以尋求到下一個字的結尾,它最終將當達到文件結尾的失敗。 默認情況下,執行移動操作一次(_n_= 1)。 If _mode_ is `KeepAnchor`,光標選擇它移動到文本上。這是當他們按住Shift鍵并移動光標,光標鍵,用戶達到相同的效果。 **See also** [setVisualNavigation](qtextcursor.html#setVisualNavigation)( ) 。 ``` int QTextCursor.position (self) ``` 返回文檔內的光標的絕對位置。將光標定位字符之間。 **See also** [setPosition](qtextcursor.html#setPosition)( )[movePosition](qtextcursor.html#movePosition)( )[anchor](qtextcursor.html#anchor)()和[positionInBlock](qtextcursor.html#positionInBlock)( ) 。 ``` int QTextCursor.positionInBlock (self) ``` 返回塊內的光標的相對位置。將光標定位字符之間。 這等效于`position() - block().position()`。 此功能被引入Qt的4.7 。 **See also** [position](qtextcursor.html#position)( ) 。 ``` QTextCursor.removeSelectedText (self) ``` 如果有選擇,它的內容將被刪除,否則什么都不做。 **See also** [hasSelection](qtextcursor.html#hasSelection)( ) 。 ``` QTextCursor.select (self, SelectionType?selection) ``` 根據給定的選擇文檔中的文本_selection_。 ``` (int?firstRow, int?numRows, int?firstColumn, int?numColumns) QTextCursor.selectedTableCells (self) ``` 如果選擇跨越表格單元格,_firstRow_填入第一行中選擇的數量,_firstColumn_以在選擇第一列的數目,并_numRows_和_numColumns_以行和列的選擇數目。如果選擇不跨越任何表格單元格的結果是無害的,但不確定。 ``` QString QTextCursor.selectedText (self) ``` 返回當前選擇的文本(可能為空) 。這只能返回文本,沒有豐富的文本格式的信息。如果你想有一個文檔片段(即格式化的富文本)的使用[selection](qtextcursor.html#selection)( )來代替。 **Note:**如果從編輯獲得的選擇跨越一個換行符,文本將包含一個Unicode ü 2029段分隔符,而不是一個換行符`\n`字符。使用[QString.replace](qstring.html#replace)()與換行符替換這些字符。 ``` QTextDocumentFragment QTextCursor.selection (self) ``` [](qtextdocumentfragment.html) [返回當前的選擇(可能為空) ,其所有的格式化信息。如果你只是想選定的文本(即純文本)的使用](qtextdocumentfragment.html)[selectedText](qtextcursor.html#selectedText)( )來代替。 **Note:**不像[QTextDocumentFragment.toPlainText](qtextdocumentfragment.html#toPlainText)( )[selectedText](qtextcursor.html#selectedText)( )可能包括特殊的Unicode字符,如[QChar.ParagraphSeparator](qchar.html#SpecialCharacter-enum)。 **See also** [QTextDocumentFragment.toPlainText](qtextdocumentfragment.html#toPlainText)( ) 。 ``` int QTextCursor.selectionEnd (self) ``` 返回所選內容的末尾或[position](qtextcursor.html#position)()如果光標沒有選擇。 **See also** [selectionStart](qtextcursor.html#selectionStart)( )[position](qtextcursor.html#position)()和[anchor](qtextcursor.html#anchor)( ) 。 ``` int QTextCursor.selectionStart (self) ``` 返回所選內容的開始或[position](qtextcursor.html#position)()如果光標沒有選擇。 **See also** [selectionEnd](qtextcursor.html#selectionEnd)( )[position](qtextcursor.html#position)()和[anchor](qtextcursor.html#anchor)( ) 。 ``` QTextCursor.setBlockCharFormat (self, QTextCharFormat?format) ``` 設置當前塊的塊char格式(或包含在選區中的所有塊) ,以_format_。 **See also** [blockCharFormat](qtextcursor.html#blockCharFormat)( ) 。 ``` QTextCursor.setBlockFormat (self, QTextBlockFormat?format) ``` 將當前塊的塊格式(或包含在選擇的所有塊),以_format_。 **See also** [blockFormat](qtextcursor.html#blockFormat)()和[mergeBlockFormat](qtextcursor.html#mergeBlockFormat)( ) 。 ``` QTextCursor.setCharFormat (self, QTextCharFormat?format) ``` 設置光標的當前字符格式到給定_format_。如果光標有一個選擇,給定的_format_應用到當前的選擇。 **See also** [charFormat](qtextcursor.html#charFormat)( )[hasSelection](qtextcursor.html#hasSelection)()和[mergeCharFormat](qtextcursor.html#mergeCharFormat)( ) 。 ``` QTextCursor.setKeepPositionOnInsert (self, bool?b) ``` 定義游標是否應保持其目前的位置,當文本被插入到光標的當前位置。 If _b_誠然,光標保持其當前位置,當文字被插入到光標的:放置。如果_b_是假的,光標移動隨插入的文本。 默認值為False 。 請注意,光標移動始終文本時,光標的當前位置之前插入,并且始終保持其位置時,文本光標的當前位置后插入。 此功能被引入Qt的4.7 。 **See also** [keepPositionOnInsert](qtextcursor.html#keepPositionOnInsert)( ) 。 ``` QTextCursor.setPosition (self, int?pos, MoveMode?mode?=?QTextCursor.MoveAnchor) ``` 將光標移動到所指定的文件中的絕對位置_pos_使用`MoveMode`通過指定_m_。將光標定位字符之間。 **See also** [position](qtextcursor.html#position)( )[movePosition](qtextcursor.html#movePosition)()和[anchor](qtextcursor.html#anchor)( ) 。 ``` QTextCursor.setVerticalMovementX (self, int?x) ``` 設置為垂直光標運動的視覺x位置,以_x_。 垂直運動x位置自動清零當光標水平移動,并保持不變,當光標上下移動。該機制允許光標上下移動以與比例字體在視覺上的直線,并輕輕地“跳”過短的線路。 值-1表示沒有預定義的x位置。然后,它會自動在下一次光標向上或向下移動設置。 此功能被引入Qt的4.7 。 **See also** [verticalMovementX](qtextcursor.html#verticalMovementX)( ) 。 ``` QTextCursor.setVisualNavigation (self, bool?b) ``` 設置視覺導航到_b_。 視覺導航是指跳過隱藏的文本pragraphs 。默認值為False 。 此功能被引入Qt的4.4 。 **See also** [visualNavigation](qtextcursor.html#visualNavigation)()和[movePosition](qtextcursor.html#movePosition)( ) 。 ``` int QTextCursor.verticalMovementX (self) ``` 返回垂直光標運動的視覺x位置。 值-1表示沒有預定義的x位置。然后,它會自動在下一次光標向上或向下移動設置。 此功能被引入Qt的4.7 。 **See also** [setVerticalMovementX](qtextcursor.html#setVerticalMovementX)( ) 。 ``` bool QTextCursor.visualNavigation (self) ``` 返回True如果光標做視覺導航;否則返回False。 視覺導航是指跳過隱藏的文本pragraphs 。默認值為False 。 此功能被引入Qt的4.4 。 **See also** [setVisualNavigation](qtextcursor.html#setVisualNavigation)()和[movePosition](qtextcursor.html#movePosition)( ) 。 ``` bool QTextCursor.__eq__ (self, QTextCursor?rhs) ``` ``` bool QTextCursor.__ge__ (self, QTextCursor?rhs) ``` ``` bool QTextCursor.__gt__ (self, QTextCursor?rhs) ``` ``` bool QTextCursor.__le__ (self, QTextCursor?rhs) ``` ``` bool QTextCursor.__lt__ (self, QTextCursor?rhs) ``` ``` bool QTextCursor.__ne__ (self, QTextCursor?rhs) ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看