1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805
|
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QTextCursor Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">  </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QTextCursor Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QTextCursor class offers an API to access and modify
QTextDocuments. <a href="#details">More...</a></p>
<h3>Types</h3><ul><li><div class="fn" />enum <b><a href="qtextcursor.html#MoveMode-enum">MoveMode</a></b> { MoveAnchor, KeepAnchor }</li><li><div class="fn" />enum <b><a href="qtextcursor.html#MoveOperation-enum">MoveOperation</a></b> { NoMove, Start, Up, StartOfLine, ..., PreviousRow }</li><li><div class="fn" />enum <b><a href="qtextcursor.html#SelectionType-enum">SelectionType</a></b> { WordUnderCursor, LineUnderCursor, BlockUnderCursor, Document }</li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qtextcursor.html#QTextCursor">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtextcursor.html#QTextCursor-2">__init__</a></b> (<i>self</i>, QTextDocument <i>document</i>)</li><li><div class="fn" /><b><a href="qtextcursor.html#QTextCursor-3">__init__</a></b> (<i>self</i>, QTextFrame <i>frame</i>)</li><li><div class="fn" /><b><a href="qtextcursor.html#QTextCursor-4">__init__</a></b> (<i>self</i>, QTextBlock <i>block</i>)</li><li><div class="fn" /><b><a href="qtextcursor.html#QTextCursor-5">__init__</a></b> (<i>self</i>, QTextCursor <i>cursor</i>)</li><li><div class="fn" />int <b><a href="qtextcursor.html#anchor">anchor</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qtextcursor.html#atBlockEnd">atBlockEnd</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qtextcursor.html#atBlockStart">atBlockStart</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qtextcursor.html#atEnd">atEnd</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qtextcursor.html#atStart">atStart</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtextcursor.html#beginEditBlock">beginEditBlock</a></b> (<i>self</i>)</li><li><div class="fn" />QTextBlock <b><a href="qtextcursor.html#block">block</a></b> (<i>self</i>)</li><li><div class="fn" />QTextCharFormat <b><a href="qtextcursor.html#blockCharFormat">blockCharFormat</a></b> (<i>self</i>)</li><li><div class="fn" />QTextBlockFormat <b><a href="qtextcursor.html#blockFormat">blockFormat</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qtextcursor.html#blockNumber">blockNumber</a></b> (<i>self</i>)</li><li><div class="fn" />QTextCharFormat <b><a href="qtextcursor.html#charFormat">charFormat</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtextcursor.html#clearSelection">clearSelection</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qtextcursor.html#columnNumber">columnNumber</a></b> (<i>self</i>)</li><li><div class="fn" />QTextList <b><a href="qtextcursor.html#createList">createList</a></b> (<i>self</i>, QTextListFormat <i>format</i>)</li><li><div class="fn" />QTextList <b><a href="qtextcursor.html#createList-2">createList</a></b> (<i>self</i>, QTextListFormat.Style <i>style</i>)</li><li><div class="fn" />QTextFrame <b><a href="qtextcursor.html#currentFrame">currentFrame</a></b> (<i>self</i>)</li><li><div class="fn" />QTextList <b><a href="qtextcursor.html#currentList">currentList</a></b> (<i>self</i>)</li><li><div class="fn" />QTextTable <b><a href="qtextcursor.html#currentTable">currentTable</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtextcursor.html#deleteChar">deleteChar</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtextcursor.html#deletePreviousChar">deletePreviousChar</a></b> (<i>self</i>)</li><li><div class="fn" />QTextDocument <b><a href="qtextcursor.html#document">document</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtextcursor.html#endEditBlock">endEditBlock</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qtextcursor.html#hasComplexSelection">hasComplexSelection</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qtextcursor.html#hasSelection">hasSelection</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtextcursor.html#insertBlock">insertBlock</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtextcursor.html#insertBlock-2">insertBlock</a></b> (<i>self</i>, QTextBlockFormat <i>format</i>)</li><li><div class="fn" /><b><a href="qtextcursor.html#insertBlock-3">insertBlock</a></b> (<i>self</i>, QTextBlockFormat <i>format</i>, QTextCharFormat <i>charFormat</i>)</li><li><div class="fn" /><b><a href="qtextcursor.html#insertFragment">insertFragment</a></b> (<i>self</i>, QTextDocumentFragment <i>fragment</i>)</li><li><div class="fn" />QTextFrame <b><a href="qtextcursor.html#insertFrame">insertFrame</a></b> (<i>self</i>, QTextFrameFormat <i>format</i>)</li><li><div class="fn" /><b><a href="qtextcursor.html#insertHtml">insertHtml</a></b> (<i>self</i>, QString <i>html</i>)</li><li><div class="fn" /><b><a href="qtextcursor.html#insertImage">insertImage</a></b> (<i>self</i>, QTextImageFormat <i>format</i>)</li><li><div class="fn" /><b><a href="qtextcursor.html#insertImage-2">insertImage</a></b> (<i>self</i>, QTextImageFormat <i>format</i>, QTextFrameFormat.Position <i>alignment</i>)</li><li><div class="fn" /><b><a href="qtextcursor.html#insertImage-3">insertImage</a></b> (<i>self</i>, QString <i>name</i>)</li><li><div class="fn" /><b><a href="qtextcursor.html#insertImage-4">insertImage</a></b> (<i>self</i>, QImage <i>image</i>, QString <i>name</i> = QString())</li><li><div class="fn" />QTextList <b><a href="qtextcursor.html#insertList">insertList</a></b> (<i>self</i>, QTextListFormat <i>format</i>)</li><li><div class="fn" />QTextList <b><a href="qtextcursor.html#insertList-2">insertList</a></b> (<i>self</i>, QTextListFormat.Style <i>style</i>)</li><li><div class="fn" />QTextTable <b><a href="qtextcursor.html#insertTable">insertTable</a></b> (<i>self</i>, int <i>rows</i>, int <i>cols</i>, QTextTableFormat <i>format</i>)</li><li><div class="fn" />QTextTable <b><a href="qtextcursor.html#insertTable-2">insertTable</a></b> (<i>self</i>, int <i>rows</i>, int <i>cols</i>)</li><li><div class="fn" /><b><a href="qtextcursor.html#insertText">insertText</a></b> (<i>self</i>, QString <i>text</i>)</li><li><div class="fn" /><b><a href="qtextcursor.html#insertText-2">insertText</a></b> (<i>self</i>, QString <i>text</i>, QTextCharFormat <i>format</i>)</li><li><div class="fn" />bool <b><a href="qtextcursor.html#isCopyOf">isCopyOf</a></b> (<i>self</i>, QTextCursor <i>other</i>)</li><li><div class="fn" />bool <b><a href="qtextcursor.html#isNull">isNull</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtextcursor.html#joinPreviousEditBlock">joinPreviousEditBlock</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qtextcursor.html#keepPositionOnInsert">keepPositionOnInsert</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtextcursor.html#mergeBlockCharFormat">mergeBlockCharFormat</a></b> (<i>self</i>, QTextCharFormat <i>modifier</i>)</li><li><div class="fn" /><b><a href="qtextcursor.html#mergeBlockFormat">mergeBlockFormat</a></b> (<i>self</i>, QTextBlockFormat <i>modifier</i>)</li><li><div class="fn" /><b><a href="qtextcursor.html#mergeCharFormat">mergeCharFormat</a></b> (<i>self</i>, QTextCharFormat <i>modifier</i>)</li><li><div class="fn" />bool <b><a href="qtextcursor.html#movePosition">movePosition</a></b> (<i>self</i>, MoveOperation <i>op</i>, MoveMode <i>mode</i> = QTextCursor.MoveAnchor, int <i>n</i> = 1)</li><li><div class="fn" />int <b><a href="qtextcursor.html#position">position</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qtextcursor.html#positionInBlock">positionInBlock</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtextcursor.html#removeSelectedText">removeSelectedText</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtextcursor.html#select">select</a></b> (<i>self</i>, SelectionType <i>selection</i>)</li><li><div class="fn" />(int <i>firstRow</i>, int <i>numRows</i>, int <i>firstColumn</i>, int <i>numColumns</i>) <b><a href="qtextcursor.html#selectedTableCells">selectedTableCells</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qtextcursor.html#selectedText">selectedText</a></b> (<i>self</i>)</li><li><div class="fn" />QTextDocumentFragment <b><a href="qtextcursor.html#selection">selection</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qtextcursor.html#selectionEnd">selectionEnd</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qtextcursor.html#selectionStart">selectionStart</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtextcursor.html#setBlockCharFormat">setBlockCharFormat</a></b> (<i>self</i>, QTextCharFormat <i>format</i>)</li><li><div class="fn" /><b><a href="qtextcursor.html#setBlockFormat">setBlockFormat</a></b> (<i>self</i>, QTextBlockFormat <i>format</i>)</li><li><div class="fn" /><b><a href="qtextcursor.html#setCharFormat">setCharFormat</a></b> (<i>self</i>, QTextCharFormat <i>format</i>)</li><li><div class="fn" /><b><a href="qtextcursor.html#setKeepPositionOnInsert">setKeepPositionOnInsert</a></b> (<i>self</i>, bool <i>b</i>)</li><li><div class="fn" /><b><a href="qtextcursor.html#setPosition">setPosition</a></b> (<i>self</i>, int <i>pos</i>, MoveMode <i>mode</i> = QTextCursor.MoveAnchor)</li><li><div class="fn" /><b><a href="qtextcursor.html#setVerticalMovementX">setVerticalMovementX</a></b> (<i>self</i>, int <i>x</i>)</li><li><div class="fn" /><b><a href="qtextcursor.html#setVisualNavigation">setVisualNavigation</a></b> (<i>self</i>, bool <i>b</i>)</li><li><div class="fn" />int <b><a href="qtextcursor.html#verticalMovementX">verticalMovementX</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qtextcursor.html#visualNavigation">visualNavigation</a></b> (<i>self</i>)</li></ul><h3>Special Methods</h3><ul><li><div class="fn" />bool <b><a href="qtextcursor.html#__eq__">__eq__</a></b> (<i>self</i>, QTextCursor <i>rhs</i>)</li><li><div class="fn" />bool <b><a href="qtextcursor.html#__ge__">__ge__</a></b> (<i>self</i>, QTextCursor <i>rhs</i>)</li><li><div class="fn" />bool <b><a href="qtextcursor.html#__gt__">__gt__</a></b> (<i>self</i>, QTextCursor <i>rhs</i>)</li><li><div class="fn" />bool <b><a href="qtextcursor.html#__le__">__le__</a></b> (<i>self</i>, QTextCursor <i>rhs</i>)</li><li><div class="fn" />bool <b><a href="qtextcursor.html#__lt__">__lt__</a></b> (<i>self</i>, QTextCursor <i>rhs</i>)</li><li><div class="fn" />bool <b><a href="qtextcursor.html#__ne__">__ne__</a></b> (<i>self</i>, QTextCursor <i>rhs</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QTextCursor class offers an API to access and modify
QTextDocuments.</p>
<p>Text cursors are objects that are used to access and modify the
contents and underlying structure of text documents via a
programming interface that mimics the behavior of a cursor in a
text editor. QTextCursor contains information about both the
cursor's position within a <a href="qtextdocument.html">QTextDocument</a> and any selection that it
has made.</p>
<p>QTextCursor is modeled on the way a text cursor behaves in a
text editor, providing a programmatic means of performing standard
actions through the user interface. A document can be thought of as
a single string of characters. The cursor's current <a href="qtextcursor.html#position">position</a>() then is always either
<i>between</i> two consecutive characters in the string, or else
<i>before</i> the very first character or <i>after</i> the very
last character in the string. Documents can also contain tables,
lists, images, and other objects in addition to text but, from the
developer's point of view, the document can be treated as one long
string. Some portions of that string can be considered to lie
within particular blocks (e.g. paragraphs), or within a table's
cell, or a list's item, or other structural elements. When we refer
to "current character" we mean the character immediately
<i>before</i> the cursor <a href="qtextcursor.html#position">position</a>() in the document.
Similarly, the "current block" is the block that contains the
cursor <a href="qtextcursor.html#position">position</a>().</p>
<p>A QTextCursor also has an <a href="qtextcursor.html#anchor">anchor</a>() position. The text that is
between the <a href="qtextcursor.html#anchor">anchor</a>() and the
<a href="qtextcursor.html#position">position</a>() is the
selection. If <a href="qtextcursor.html#anchor">anchor</a>() ==
<a href="qtextcursor.html#position">position</a>() there is no
selection.</p>
<p>The cursor position can be changed programmatically using
<a href="qtextcursor.html#setPosition">setPosition</a>() and
<a href="qtextcursor.html#movePosition">movePosition</a>(); the
latter can also be used to select text. For selections see <a href="qtextcursor.html#selectionStart">selectionStart</a>(), <a href="qtextcursor.html#selectionEnd">selectionEnd</a>(), <a href="qtextcursor.html#hasSelection">hasSelection</a>(), <a href="qtextcursor.html#clearSelection">clearSelection</a>(), and
<a href="qtextcursor.html#removeSelectedText">removeSelectedText</a>().</p>
<p>If the <a href="qtextcursor.html#position">position</a>() is at
the start of a block <a href="qtextcursor.html#atBlockStart">atBlockStart</a>() returns true;
and if it is at the end of a block <a href="qtextcursor.html#atBlockEnd">atBlockEnd</a>() returns true. The
format of the current character is returned by <a href="qtextcursor.html#charFormat">charFormat</a>(), and the format of
the current block is returned by <a href="qtextcursor.html#blockFormat">blockFormat</a>().</p>
<p>Formatting can be applied to the current text document using the
<a href="qtextcursor.html#setCharFormat">setCharFormat</a>(),
<a href="qtextcursor.html#mergeCharFormat">mergeCharFormat</a>(),
<a href="qtextcursor.html#setBlockFormat">setBlockFormat</a>() and
<a href="qtextcursor.html#mergeBlockFormat">mergeBlockFormat</a>()
functions. The 'set' functions will replace the cursor's current
character or block format, while the 'merge' functions add the
given format properties to the cursor's current format. If the
cursor has a selection the given format is applied to the current
selection. Note that when only parts of a block is selected the
block format is applied to the entire block. The text at the
current character position can be turned into a list using <a href="qtextcursor.html#createList">createList</a>().</p>
<p>Deletions can be achieved using <a href="qtextcursor.html#deleteChar">deleteChar</a>(), <a href="qtextcursor.html#deletePreviousChar">deletePreviousChar</a>(), and
<a href="qtextcursor.html#removeSelectedText">removeSelectedText</a>().</p>
<p>Text strings can be inserted into the document with the <a href="qtextcursor.html#insertText">insertText</a>() function, blocks
(representing new paragraphs) can be inserted with <a href="qtextcursor.html#insertBlock">insertBlock</a>().</p>
<p>Existing fragments of text can be inserted with <a href="qtextcursor.html#insertFragment">insertFragment</a>() but, if you
want to insert pieces of text in various formats, it is usually
still easier to use <a href="qtextcursor.html#insertText">insertText</a>() and supply a
character format.</p>
<p>Various types of higher-level structure can also be inserted
into the document with the cursor:</p>
<ul>
<li>Lists are ordered sequences of block elements that are
decorated with bullet points or symbols. These are inserted in a
specified format with <a href="qtextcursor.html#insertList">insertList</a>().</li>
<li>Tables are inserted with the <a href="qtextcursor.html#insertTable">insertTable</a>() function, and can
be given an optional format. These contain an array of cells that
can be traversed using the cursor.</li>
<li>Inline images are inserted with <a href="qtextcursor.html#insertImage">insertImage</a>(). The image to be
used can be specified in an image format, or by name.</li>
<li>Frames are inserted by calling <a href="qtextcursor.html#insertFrame">insertFrame</a>() with a specified
format.</li>
</ul>
<p>Actions can be grouped (i.e. treated as a single action for
undo/redo) using <a href="qtextcursor.html#beginEditBlock">beginEditBlock</a>() and <a href="qtextcursor.html#endEditBlock">endEditBlock</a>().</p>
<p>Cursor movements are limited to valid cursor positions. In Latin
writing this is between any two consecutive characters in the text,
before the first character, or after the last character. In some
other writing systems cursor movements are limited to "clusters"
(e.g. a syllable in Devanagari, or a base letter plus diacritics).
Functions such as <a href="qtextcursor.html#movePosition">movePosition</a>() and <a href="qtextcursor.html#deleteChar">deleteChar</a>() limit cursor
movement to these valid positions.</p>
<hr /><h2>Type Documentation</h2><h3 class="fn"><a name="MoveMode-enum" />QTextCursor.MoveMode</h3><table class="valuelist">
<tr class="odd" valign="top">
<th class="tblConst">Constant</th>
<th class="tblval">Value</th>
<th class="tbldscr">Description</th>
</tr>
<tr>
<td class="topAlign"><tt>QTextCursor.MoveAnchor</tt></td>
<td class="topAlign"><tt>0</tt></td>
<td class="topAlign">Moves the anchor to the same position as the
cursor itself.</td>
</tr>
<tr>
<td class="topAlign"><tt>QTextCursor.KeepAnchor</tt></td>
<td class="topAlign"><tt>1</tt></td>
<td class="topAlign">Keeps the anchor where it is.</td>
</tr>
</table>
<p>If the <a href="qtextcursor.html#anchor">anchor</a>() is kept
where it is and the <a href="qtextcursor.html#position">position</a>() is moved, the text in
between will be selected.</p>
<h3 class="fn"><a name="MoveOperation-enum" />QTextCursor.MoveOperation</h3><table class="valuelist">
<tr class="odd" valign="top">
<th class="tblConst">Constant</th>
<th class="tblval">Value</th>
<th class="tbldscr">Description</th>
</tr>
<tr>
<td class="topAlign"><tt>QTextCursor.NoMove</tt></td>
<td class="topAlign"><tt>0</tt></td>
<td class="topAlign">Keep the cursor where it is</td>
</tr>
<tr>
<td class="topAlign"><tt>QTextCursor.Start</tt></td>
<td class="topAlign"><tt>1</tt></td>
<td class="topAlign">Move to the start of the document.</td>
</tr>
<tr>
<td class="topAlign"><tt>QTextCursor.StartOfLine</tt></td>
<td class="topAlign"><tt>3</tt></td>
<td class="topAlign">Move to the start of the current line.</td>
</tr>
<tr>
<td class="topAlign"><tt>QTextCursor.StartOfBlock</tt></td>
<td class="topAlign"><tt>4</tt></td>
<td class="topAlign">Move to the start of the current block.</td>
</tr>
<tr>
<td class="topAlign"><tt>QTextCursor.StartOfWord</tt></td>
<td class="topAlign"><tt>5</tt></td>
<td class="topAlign">Move to the start of the current word.</td>
</tr>
<tr>
<td class="topAlign"><tt>QTextCursor.PreviousBlock</tt></td>
<td class="topAlign"><tt>6</tt></td>
<td class="topAlign">Move to the start of the previous block.</td>
</tr>
<tr>
<td class="topAlign"><tt>QTextCursor.PreviousCharacter</tt></td>
<td class="topAlign"><tt>7</tt></td>
<td class="topAlign">Move to the previous character.</td>
</tr>
<tr>
<td class="topAlign"><tt>QTextCursor.PreviousWord</tt></td>
<td class="topAlign"><tt>8</tt></td>
<td class="topAlign">Move to the beginning of the previous
word.</td>
</tr>
<tr>
<td class="topAlign"><tt>QTextCursor.Up</tt></td>
<td class="topAlign"><tt>2</tt></td>
<td class="topAlign">Move up one line.</td>
</tr>
<tr>
<td class="topAlign"><tt>QTextCursor.Left</tt></td>
<td class="topAlign"><tt>9</tt></td>
<td class="topAlign">Move left one character.</td>
</tr>
<tr>
<td class="topAlign"><tt>QTextCursor.WordLeft</tt></td>
<td class="topAlign"><tt>10</tt></td>
<td class="topAlign">Move left one word.</td>
</tr>
<tr>
<td class="topAlign"><tt>QTextCursor.End</tt></td>
<td class="topAlign"><tt>11</tt></td>
<td class="topAlign">Move to the end of the document.</td>
</tr>
<tr>
<td class="topAlign"><tt>QTextCursor.EndOfLine</tt></td>
<td class="topAlign"><tt>13</tt></td>
<td class="topAlign">Move to the end of the current line.</td>
</tr>
<tr>
<td class="topAlign"><tt>QTextCursor.EndOfWord</tt></td>
<td class="topAlign"><tt>14</tt></td>
<td class="topAlign">Move to the end of the current word.</td>
</tr>
<tr>
<td class="topAlign"><tt>QTextCursor.EndOfBlock</tt></td>
<td class="topAlign"><tt>15</tt></td>
<td class="topAlign">Move to the end of the current block.</td>
</tr>
<tr>
<td class="topAlign"><tt>QTextCursor.NextBlock</tt></td>
<td class="topAlign"><tt>16</tt></td>
<td class="topAlign">Move to the beginning of the next block.</td>
</tr>
<tr>
<td class="topAlign"><tt>QTextCursor.NextCharacter</tt></td>
<td class="topAlign"><tt>17</tt></td>
<td class="topAlign">Move to the next character.</td>
</tr>
<tr>
<td class="topAlign"><tt>QTextCursor.NextWord</tt></td>
<td class="topAlign"><tt>18</tt></td>
<td class="topAlign">Move to the next word.</td>
</tr>
<tr>
<td class="topAlign"><tt>QTextCursor.Down</tt></td>
<td class="topAlign"><tt>12</tt></td>
<td class="topAlign">Move down one line.</td>
</tr>
<tr>
<td class="topAlign"><tt>QTextCursor.Right</tt></td>
<td class="topAlign"><tt>19</tt></td>
<td class="topAlign">Move right one character.</td>
</tr>
<tr>
<td class="topAlign"><tt>QTextCursor.WordRight</tt></td>
<td class="topAlign"><tt>20</tt></td>
<td class="topAlign">Move right one word.</td>
</tr>
<tr>
<td class="topAlign"><tt>QTextCursor.NextCell</tt></td>
<td class="topAlign"><tt>21</tt></td>
<td class="topAlign">Move to the beginning of the next table cell
inside the current table. If the current cell is the last cell in
the row, the cursor will move to the first cell in the next
row.</td>
</tr>
<tr>
<td class="topAlign"><tt>QTextCursor.PreviousCell</tt></td>
<td class="topAlign"><tt>22</tt></td>
<td class="topAlign">Move to the beginning of the previous table
cell inside the current table. If the current cell is the first
cell in the row, the cursor will move to the last cell in the
previous row.</td>
</tr>
<tr>
<td class="topAlign"><tt>QTextCursor.NextRow</tt></td>
<td class="topAlign"><tt>23</tt></td>
<td class="topAlign">Move to the first new cell of the next row in
the current table.</td>
</tr>
<tr>
<td class="topAlign"><tt>QTextCursor.PreviousRow</tt></td>
<td class="topAlign"><tt>24</tt></td>
<td class="topAlign">Move to the last cell of the previous row in
the current table.</td>
</tr>
</table>
<p><b>See also</b> <a href="qtextcursor.html#movePosition">movePosition</a>().</p>
<h3 class="fn"><a name="SelectionType-enum" />QTextCursor.SelectionType</h3><p>This enum describes the types of selection that can be applied
with the <a href="qtextcursor.html#select">select</a>()
function.</p>
<table class="valuelist">
<tr class="odd" valign="top">
<th class="tblConst">Constant</th>
<th class="tblval">Value</th>
<th class="tbldscr">Description</th>
</tr>
<tr>
<td class="topAlign"><tt>QTextCursor.Document</tt></td>
<td class="topAlign"><tt>3</tt></td>
<td class="topAlign">Selects the entire document.</td>
</tr>
<tr>
<td class="topAlign"><tt>QTextCursor.BlockUnderCursor</tt></td>
<td class="topAlign"><tt>2</tt></td>
<td class="topAlign">Selects the block of text under the
cursor.</td>
</tr>
<tr>
<td class="topAlign"><tt>QTextCursor.LineUnderCursor</tt></td>
<td class="topAlign"><tt>1</tt></td>
<td class="topAlign">Selects the line of text under the
cursor.</td>
</tr>
<tr>
<td class="topAlign"><tt>QTextCursor.WordUnderCursor</tt></td>
<td class="topAlign"><tt>0</tt></td>
<td class="topAlign">Selects the word under the cursor. If the
cursor is not positioned within a string of selectable characters,
no text is selected.</td>
</tr>
</table>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QTextCursor" />QTextCursor.__init__ (<i>self</i>)</h3><p>Constructs a null cursor.</p>
<h3 class="fn"><a name="QTextCursor-2" />QTextCursor.__init__ (<i>self</i>, <a href="qtextdocument.html">QTextDocument</a> <i>document</i>)</h3><p>Constructs a cursor pointing to the beginning of the
<i>document</i>.</p>
<h3 class="fn"><a name="QTextCursor-3" />QTextCursor.__init__ (<i>self</i>, <a href="qtextframe.html">QTextFrame</a> <i>frame</i>)</h3><h3 class="fn"><a name="QTextCursor-4" />QTextCursor.__init__ (<i>self</i>, <a href="qtextblock.html">QTextBlock</a> <i>block</i>)</h3><p>Constructs a cursor pointing to the beginning of the
<i>frame</i>.</p>
<h3 class="fn"><a name="QTextCursor-5" />QTextCursor.__init__ (<i>self</i>, <a href="qtextcursor.html">QTextCursor</a> <i>cursor</i>)</h3><p>Constructs a cursor pointing to the beginning of the
<i>block</i>.</p>
<h3 class="fn"><a name="anchor" />int QTextCursor.anchor (<i>self</i>)</h3><p>Returns the anchor position; this is the same as <a href="qtextcursor.html#position">position</a>() unless there is a
selection in which case <a href="qtextcursor.html#position">position</a>() marks one end of the
selection and anchor() marks the other end. Just like the cursor
position, the anchor position is between characters.</p>
<p><b>See also</b> <a href="qtextcursor.html#position">position</a>(), <a href="qtextcursor.html#setPosition">setPosition</a>(), <a href="qtextcursor.html#movePosition">movePosition</a>(), <a href="qtextcursor.html#selectionStart">selectionStart</a>(), and
<a href="qtextcursor.html#selectionEnd">selectionEnd</a>().</p>
<h3 class="fn"><a name="atBlockEnd" />bool QTextCursor.atBlockEnd (<i>self</i>)</h3><p>Returns true if the cursor is at the end of a block; otherwise
returns false.</p>
<p><b>See also</b> <a href="qtextcursor.html#atBlockStart">atBlockStart</a>() and <a href="qtextcursor.html#atEnd">atEnd</a>().</p>
<h3 class="fn"><a name="atBlockStart" />bool QTextCursor.atBlockStart (<i>self</i>)</h3><p>Returns true if the cursor is at the start of a block; otherwise
returns false.</p>
<p><b>See also</b> <a href="qtextcursor.html#atBlockEnd">atBlockEnd</a>() and <a href="qtextcursor.html#atStart">atStart</a>().</p>
<h3 class="fn"><a name="atEnd" />bool QTextCursor.atEnd (<i>self</i>)</h3><p>Returns true if the cursor is at the end of the document;
otherwise returns false.</p>
<p>This function was introduced in Qt 4.6.</p>
<p><b>See also</b> <a href="qtextcursor.html#atStart">atStart</a>()
and <a href="qtextcursor.html#atBlockEnd">atBlockEnd</a>().</p>
<h3 class="fn"><a name="atStart" />bool QTextCursor.atStart (<i>self</i>)</h3><p>Returns true if the cursor is at the start of the document;
otherwise returns false.</p>
<p><b>See also</b> <a href="qtextcursor.html#atBlockStart">atBlockStart</a>() and <a href="qtextcursor.html#atEnd">atEnd</a>().</p>
<h3 class="fn"><a name="beginEditBlock" />QTextCursor.beginEditBlock (<i>self</i>)</h3><p>Indicates the start of a block of editing operations on the
document that should appear as a single operation from an undo/redo
point of view.</p>
<p>For example:</p>
<pre class="cpp">
<span class="type"><a href="qtextcursor.html">QTextCursor</a></span> cursor(textDocument);
cursor<span class="operator">.</span>beginEditBlock();
cursor<span class="operator">.</span><a href="qtextcursor.html#insertText">insertText</a>(<span class="string">"Hello"</span>);
cursor<span class="operator">.</span><a href="qtextcursor.html#insertText">insertText</a>(<span class="string">"World"</span>);
cursor<span class="operator">.</span><a href="qtextcursor.html#endEditBlock">endEditBlock</a>();
textDocument<span class="operator">-</span><span class="operator">></span>undo();
</pre>
<p>The call to undo() will cause both insertions to be undone,
causing both "World" and "Hello" to be removed.</p>
<p>It is possible to nest calls to beginEditBlock and endEditBlock.
The top-most pair will determine the scope of the undo/redo
operation.</p>
<p><b>See also</b> <a href="qtextcursor.html#endEditBlock">endEditBlock</a>().</p>
<h3 class="fn"><a name="block" /><a href="qtextblock.html">QTextBlock</a> QTextCursor.block (<i>self</i>)</h3><p>Returns the block that contains the cursor.</p>
<h3 class="fn"><a name="blockCharFormat" /><a href="qtextcharformat.html">QTextCharFormat</a> QTextCursor.blockCharFormat (<i>self</i>)</h3><p>Returns the block character format of the block the cursor is
in.</p>
<p>The block char format is the format used when inserting text at
the beginning of an empty block.</p>
<p><b>See also</b> <a href="qtextcursor.html#setBlockCharFormat">setBlockCharFormat</a>().</p>
<h3 class="fn"><a name="blockFormat" /><a href="qtextblockformat.html">QTextBlockFormat</a> QTextCursor.blockFormat (<i>self</i>)</h3><p>Returns the block format of the block the cursor is in.</p>
<p><b>See also</b> <a href="qtextcursor.html#setBlockFormat">setBlockFormat</a>() and <a href="qtextcursor.html#charFormat">charFormat</a>().</p>
<h3 class="fn"><a name="blockNumber" />int QTextCursor.blockNumber (<i>self</i>)</h3><p>Returns the number of the block the cursor is in, or 0 if the
cursor is invalid.</p>
<p>Note that this function only makes sense in documents without
complex objects such as tables or frames.</p>
<p>This function was introduced in Qt 4.2.</p>
<h3 class="fn"><a name="charFormat" /><a href="qtextcharformat.html">QTextCharFormat</a> QTextCursor.charFormat (<i>self</i>)</h3><p>Returns the format of the character immediately before the
cursor <a href="qtextcursor.html#position">position</a>(). If the
cursor is positioned at the beginning of a text block that is not
empty then the format of the character immediately after the cursor
is returned.</p>
<p><b>See also</b> <a href="qtextcursor.html#setCharFormat">setCharFormat</a>(), <a href="qtextcursor.html#insertText">insertText</a>(), and <a href="qtextcursor.html#blockFormat">blockFormat</a>().</p>
<h3 class="fn"><a name="clearSelection" />QTextCursor.clearSelection (<i>self</i>)</h3><p>Clears the current selection by setting the anchor to the cursor
position.</p>
<p>Note that it does <b>not</b> delete the text of the
selection.</p>
<p><b>See also</b> <a href="qtextcursor.html#removeSelectedText">removeSelectedText</a>() and
<a href="qtextcursor.html#hasSelection">hasSelection</a>().</p>
<h3 class="fn"><a name="columnNumber" />int QTextCursor.columnNumber (<i>self</i>)</h3><p>Returns the position of the cursor within its containing
line.</p>
<p>Note that this is the column number relative to a wrapped line,
not relative to the block (i.e. the paragraph).</p>
<p>You probably want to call <a href="qtextcursor.html#positionInBlock">positionInBlock</a>()
instead.</p>
<p>This function was introduced in Qt 4.2.</p>
<p><b>See also</b> <a href="qtextcursor.html#positionInBlock">positionInBlock</a>().</p>
<h3 class="fn"><a name="createList" /><a href="qtextlist.html">QTextList</a> QTextCursor.createList (<i>self</i>, <a href="qtextlistformat.html">QTextListFormat</a> <i>format</i>)</h3><p>Creates and returns a new list with the given <i>format</i>, and
makes the current paragraph the cursor is in the first list
item.</p>
<p><b>See also</b> <a href="qtextcursor.html#insertList">insertList</a>() and <a href="qtextcursor.html#currentList">currentList</a>().</p>
<h3 class="fn"><a name="createList-2" /><a href="qtextlist.html">QTextList</a> QTextCursor.createList (<i>self</i>, <a href="qtextlistformat.html#Style-enum">QTextListFormat.Style</a> <i>style</i>)</h3><p>This is an overloaded function.</p>
<p>Creates and returns a new list with the given <i>style</i>,
making the cursor's current paragraph the first list item.</p>
<p>The style to be used is defined by the <a href="qtextlistformat.html#Style-enum">QTextListFormat.Style</a>
enum.</p>
<p><b>See also</b> <a href="qtextcursor.html#insertList">insertList</a>() and <a href="qtextcursor.html#currentList">currentList</a>().</p>
<h3 class="fn"><a name="currentFrame" /><a href="qtextframe.html">QTextFrame</a> QTextCursor.currentFrame (<i>self</i>)</h3><p>Returns a pointer to the current frame. Returns 0 if the cursor
is invalid.</p>
<p><b>See also</b> <a href="qtextcursor.html#insertFrame">insertFrame</a>().</p>
<h3 class="fn"><a name="currentList" /><a href="qtextlist.html">QTextList</a> QTextCursor.currentList (<i>self</i>)</h3><p>Returns the current list if the cursor <a href="qtextcursor.html#position">position</a>() is inside a block that
is part of a list; otherwise returns 0.</p>
<p><b>See also</b> <a href="qtextcursor.html#insertList">insertList</a>() and <a href="qtextcursor.html#createList">createList</a>().</p>
<h3 class="fn"><a name="currentTable" /><a href="qtexttable.html">QTextTable</a> QTextCursor.currentTable (<i>self</i>)</h3><p>Returns a pointer to the current table if the cursor <a href="qtextcursor.html#position">position</a>() is inside a block that
is part of a table; otherwise returns 0.</p>
<p><b>See also</b> <a href="qtextcursor.html#insertTable">insertTable</a>().</p>
<h3 class="fn"><a name="deleteChar" />QTextCursor.deleteChar (<i>self</i>)</h3><p>If there is no selected text, deletes the character <i>at</i>
the current cursor position; otherwise deletes the selected
text.</p>
<p><b>See also</b> <a href="qtextcursor.html#deletePreviousChar">deletePreviousChar</a>(),
<a href="qtextcursor.html#hasSelection">hasSelection</a>(), and
<a href="qtextcursor.html#clearSelection">clearSelection</a>().</p>
<h3 class="fn"><a name="deletePreviousChar" />QTextCursor.deletePreviousChar (<i>self</i>)</h3><p>If there is no selected text, deletes the character
<i>before</i> the current cursor position; otherwise deletes the
selected text.</p>
<p><b>See also</b> <a href="qtextcursor.html#deleteChar">deleteChar</a>(), <a href="qtextcursor.html#hasSelection">hasSelection</a>(), and <a href="qtextcursor.html#clearSelection">clearSelection</a>().</p>
<h3 class="fn"><a name="document" /><a href="qtextdocument.html">QTextDocument</a> QTextCursor.document (<i>self</i>)</h3><p>Returns the document this cursor is associated with.</p>
<p>This function was introduced in Qt 4.5.</p>
<h3 class="fn"><a name="endEditBlock" />QTextCursor.endEditBlock (<i>self</i>)</h3><p>Indicates the end of a block of editing operations on the
document that should appear as a single operation from an undo/redo
point of view.</p>
<p><b>See also</b> <a href="qtextcursor.html#beginEditBlock">beginEditBlock</a>().</p>
<h3 class="fn"><a name="hasComplexSelection" />bool QTextCursor.hasComplexSelection (<i>self</i>)</h3><p>Returns true if the cursor contains a selection that is not
simply a range from <a href="qtextcursor.html#selectionStart">selectionStart</a>() to <a href="qtextcursor.html#selectionEnd">selectionEnd</a>(); otherwise
returns false.</p>
<p>Complex selections are ones that span at least two cells in a
table; their extent is specified by <a href="qtextcursor.html#selectedTableCells">selectedTableCells</a>().</p>
<h3 class="fn"><a name="hasSelection" />bool QTextCursor.hasSelection (<i>self</i>)</h3><p>Returns true if the cursor contains a selection; otherwise
returns false.</p>
<h3 class="fn"><a name="insertBlock" />QTextCursor.insertBlock (<i>self</i>)</h3><p>Inserts a new empty block at the cursor <a href="qtextcursor.html#position">position</a>() with the current
<a href="qtextcursor.html#blockFormat">blockFormat</a>() and
<a href="qtextcursor.html#charFormat">charFormat</a>().</p>
<p><b>See also</b> <a href="qtextcursor.html#setBlockFormat">setBlockFormat</a>().</p>
<h3 class="fn"><a name="insertBlock-2" />QTextCursor.insertBlock (<i>self</i>, <a href="qtextblockformat.html">QTextBlockFormat</a> <i>format</i>)</h3><p>This is an overloaded function.</p>
<p>Inserts a new empty block at the cursor <a href="qtextcursor.html#position">position</a>() with block format
<i>format</i> and the current <a href="qtextcursor.html#charFormat">charFormat</a>() as block char
format.</p>
<p><b>See also</b> <a href="qtextcursor.html#setBlockFormat">setBlockFormat</a>().</p>
<h3 class="fn"><a name="insertBlock-3" />QTextCursor.insertBlock (<i>self</i>, <a href="qtextblockformat.html">QTextBlockFormat</a> <i>format</i>, <a href="qtextcharformat.html">QTextCharFormat</a> <i>charFormat</i>)</h3><p>This is an overloaded function.</p>
<p>Inserts a new empty block at the cursor <a href="qtextcursor.html#position">position</a>() with block format
<i>format</i> and <i>charFormat</i> as block char format.</p>
<p><b>See also</b> <a href="qtextcursor.html#setBlockFormat">setBlockFormat</a>().</p>
<h3 class="fn"><a name="insertFragment" />QTextCursor.insertFragment (<i>self</i>, <a href="qtextdocumentfragment.html">QTextDocumentFragment</a> <i>fragment</i>)</h3><p>Inserts the text <i>fragment</i> at the current <a href="qtextcursor.html#position">position</a>().</p>
<h3 class="fn"><a name="insertFrame" /><a href="qtextframe.html">QTextFrame</a> QTextCursor.insertFrame (<i>self</i>, <a href="qtextframeformat.html">QTextFrameFormat</a> <i>format</i>)</h3><p>Inserts a frame with the given <i>format</i> at the current
cursor <a href="qtextcursor.html#position">position</a>(), moves
the cursor <a href="qtextcursor.html#position">position</a>()
inside the frame, and returns the frame.</p>
<p>If the cursor holds a selection, the whole selection is moved
inside the frame.</p>
<p><b>See also</b> <a href="qtextcursor.html#hasSelection">hasSelection</a>().</p>
<h3 class="fn"><a name="insertHtml" />QTextCursor.insertHtml (<i>self</i>, QString <i>html</i>)</h3><p>Inserts the text <i>html</i> at the current <a href="qtextcursor.html#position">position</a>(). The text is interpreted
as HTML.</p>
<p><b>Note:</b> 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 <a href="qtextdocument.html#defaultStyleSheet-prop">QTextDocument.setDefaultStyleSheet</a>()
instead.</p>
<p>This function was introduced in Qt 4.2.</p>
<h3 class="fn"><a name="insertImage" />QTextCursor.insertImage (<i>self</i>, <a href="qtextimageformat.html">QTextImageFormat</a> <i>format</i>)</h3><p>Inserts the image defined by <i>format</i> at the current
<a href="qtextcursor.html#position">position</a>().</p>
<h3 class="fn"><a name="insertImage-2" />QTextCursor.insertImage (<i>self</i>, <a href="qtextimageformat.html">QTextImageFormat</a> <i>format</i>, <a href="qtextframeformat.html#Position-enum">QTextFrameFormat.Position</a> <i>alignment</i>)</h3><p>This is an overloaded function.</p>
<p>Inserts the image defined by the given <i>format</i> at the
cursor's current position with the specified <i>alignment</i>.</p>
<p>This function was introduced in Qt 4.2.</p>
<p><b>See also</b> <a href="qtextcursor.html#position">position</a>().</p>
<h3 class="fn"><a name="insertImage-3" />QTextCursor.insertImage (<i>self</i>, QString <i>name</i>)</h3><p>This is an overloaded function.</p>
<p>Convenience method for inserting the image with the given
<i>name</i> at the current <a href="qtextcursor.html#position">position</a>().</p>
<pre class="cpp">
<span class="type"><a href="qimage.html">QImage</a></span> img <span class="operator">=</span> <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
textDocument<span class="operator">-</span><span class="operator">></span>addResource(<span class="type"><a href="qtextdocument.html">QTextDocument</a></span><span class="operator">.</span>ImageResource<span class="operator">,</span> <span class="type"><a href="qurl.html">QUrl</a></span>(<span class="string">"myimage"</span>)<span class="operator">,</span> img);
cursor<span class="operator">.</span><a href="qtextcursor.html#insertImage">insertImage</a>(<span class="string">"myimage"</span>);
</pre>
<h3 class="fn"><a name="insertImage-4" />QTextCursor.insertImage (<i>self</i>, <a href="qimage.html">QImage</a> <i>image</i>, QString <i>name</i> = QString())</h3><p>This is an overloaded function.</p>
<p>Convenience function for inserting the given <i>image</i> with
an optional <i>name</i> at the current <a href="qtextcursor.html#position">position</a>().</p>
<p>This function was introduced in Qt 4.5.</p>
<h3 class="fn"><a name="insertList" /><a href="qtextlist.html">QTextList</a> QTextCursor.insertList (<i>self</i>, <a href="qtextlistformat.html">QTextListFormat</a> <i>format</i>)</h3><p>Inserts a new block at the current position and makes it the
first list item of a newly created list with the given
<i>format</i>. Returns the created list.</p>
<p><b>See also</b> <a href="qtextcursor.html#currentList">currentList</a>(), <a href="qtextcursor.html#createList">createList</a>(), and <a href="qtextcursor.html#insertBlock">insertBlock</a>().</p>
<h3 class="fn"><a name="insertList-2" /><a href="qtextlist.html">QTextList</a> QTextCursor.insertList (<i>self</i>, <a href="qtextlistformat.html#Style-enum">QTextListFormat.Style</a> <i>style</i>)</h3><p>This is an overloaded function.</p>
<p>Inserts a new block at the current position and makes it the
first list item of a newly created list with the given
<i>style</i>. Returns the created list.</p>
<p><b>See also</b> <a href="qtextcursor.html#currentList">currentList</a>(), <a href="qtextcursor.html#createList">createList</a>(), and <a href="qtextcursor.html#insertBlock">insertBlock</a>().</p>
<h3 class="fn"><a name="insertTable" /><a href="qtexttable.html">QTextTable</a> QTextCursor.insertTable (<i>self</i>, int <i>rows</i>, int <i>cols</i>, <a href="qtexttableformat.html">QTextTableFormat</a> <i>format</i>)</h3><p>Creates a new table with the given number of <i>rows</i> and
<i>columns</i> in the specified <i>format</i>, inserts it at the
current cursor <a href="qtextcursor.html#position">position</a>()
in the document, and returns the table object. The cursor is moved
to the beginning of the first cell.</p>
<p>There must be at least one row and one column in the table.</p>
<p><b>See also</b> <a href="qtextcursor.html#currentTable">currentTable</a>().</p>
<h3 class="fn"><a name="insertTable-2" /><a href="qtexttable.html">QTextTable</a> QTextCursor.insertTable (<i>self</i>, int <i>rows</i>, int <i>cols</i>)</h3><p>This is an overloaded function.</p>
<p>Creates a new table with the given number of <i>rows</i> and
<i>columns</i>, inserts it at the current cursor <a href="qtextcursor.html#position">position</a>() in the document, and
returns the table object. The cursor is moved to the beginning of
the first cell.</p>
<p>There must be at least one row and one column in the table.</p>
<p><b>See also</b> <a href="qtextcursor.html#currentTable">currentTable</a>().</p>
<h3 class="fn"><a name="insertText" />QTextCursor.insertText (<i>self</i>, QString <i>text</i>)</h3><p>Inserts <i>text</i> at the current position, using the current
character format.</p>
<p>If there is a selection, the selection is deleted and replaced
by <i>text</i>, for example:</p>
<pre class="cpp">
cursor<span class="operator">.</span><a href="qtextcursor.html#clearSelection">clearSelection</a>();
cursor<span class="operator">.</span><a href="qtextcursor.html#movePosition">movePosition</a>(<span class="type"><a href="qtextcursor.html">QTextCursor</a></span><span class="operator">.</span>NextWord<span class="operator">,</span> <span class="type"><a href="qtextcursor.html">QTextCursor</a></span><span class="operator">.</span>KeepAnchor);
cursor<span class="operator">.</span>insertText(<span class="string">"Hello World"</span>);
</pre>
<p>This clears any existing selection, selects the word at the
cursor (i.e. from <a href="qtextcursor.html#position">position</a>() forward), and replaces
the selection with the phrase "Hello World".</p>
<p>Any ASCII linefeed characters (\n) in the inserted text are
transformed into unicode block separators, corresponding to
<a href="qtextcursor.html#insertBlock">insertBlock</a>() calls.</p>
<p><b>See also</b> <a href="qtextcursor.html#charFormat">charFormat</a>() and <a href="qtextcursor.html#hasSelection">hasSelection</a>().</p>
<h3 class="fn"><a name="insertText-2" />QTextCursor.insertText (<i>self</i>, QString <i>text</i>, <a href="qtextcharformat.html">QTextCharFormat</a> <i>format</i>)</h3><p>This is an overloaded function.</p>
<p>Inserts <i>text</i> at the current position with the given
<i>format</i>.</p>
<h3 class="fn"><a name="isCopyOf" />bool QTextCursor.isCopyOf (<i>self</i>, <a href="qtextcursor.html">QTextCursor</a> <i>other</i>)</h3><p>Returns true if this cursor and <i>other</i> are copies of each
other, i.e. one of them was created as a copy of the other and
neither has moved since. This is much stricter than equality.</p>
<p><b>See also</b> <a href="qtextcursor.html#operator-eq">operator=</a>() and <a href="qtextcursor.html#operator-eq-eq">operator==</a>().</p>
<h3 class="fn"><a name="isNull" />bool QTextCursor.isNull (<i>self</i>)</h3><p>Returns true if the cursor is null; otherwise returns false. A
null cursor is created by the default constructor.</p>
<h3 class="fn"><a name="joinPreviousEditBlock" />QTextCursor.joinPreviousEditBlock (<i>self</i>)</h3><p>Like <a href="qtextcursor.html#beginEditBlock">beginEditBlock</a>() indicates
the start of a block of editing operations that should appear as a
single operation for undo/redo. However unlike <a href="qtextcursor.html#beginEditBlock">beginEditBlock</a>() it does not
start a new block but reverses the previous call to <a href="qtextcursor.html#endEditBlock">endEditBlock</a>() and therefore
makes following operations part of the previous edit block
created.</p>
<p>For example:</p>
<pre class="cpp">
<span class="type"><a href="qtextcursor.html">QTextCursor</a></span> cursor(textDocument);
cursor<span class="operator">.</span><a href="qtextcursor.html#beginEditBlock">beginEditBlock</a>();
cursor<span class="operator">.</span><a href="qtextcursor.html#insertText">insertText</a>(<span class="string">"Hello"</span>);
cursor<span class="operator">.</span><a href="qtextcursor.html#insertText">insertText</a>(<span class="string">"World"</span>);
cursor<span class="operator">.</span><a href="qtextcursor.html#endEditBlock">endEditBlock</a>();
<span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
cursor<span class="operator">.</span>joinPreviousEditBlock();
cursor<span class="operator">.</span><a href="qtextcursor.html#insertText">insertText</a>(<span class="string">"Hey"</span>);
cursor<span class="operator">.</span><a href="qtextcursor.html#endEditBlock">endEditBlock</a>();
textDocument<span class="operator">-</span><span class="operator">></span>undo();
</pre>
<p>The call to undo() will cause all three insertions to be
undone.</p>
<p><b>See also</b> <a href="qtextcursor.html#beginEditBlock">beginEditBlock</a>() and <a href="qtextcursor.html#endEditBlock">endEditBlock</a>().</p>
<h3 class="fn"><a name="keepPositionOnInsert" />bool QTextCursor.keepPositionOnInsert (<i>self</i>)</h3><p>Returns whether the cursor should keep its current position when
text gets inserted at the position of the cursor.</p>
<p>The default is false;</p>
<p>This function was introduced in Qt 4.7.</p>
<p><b>See also</b> <a href="qtextcursor.html#setKeepPositionOnInsert">setKeepPositionOnInsert</a>().</p>
<h3 class="fn"><a name="mergeBlockCharFormat" />QTextCursor.mergeBlockCharFormat (<i>self</i>, <a href="qtextcharformat.html">QTextCharFormat</a> <i>modifier</i>)</h3><p>Modifies the block char format of the current block (or all
blocks that are contained in the selection) with the block format
specified by <i>modifier</i>.</p>
<p><b>See also</b> <a href="qtextcursor.html#setBlockCharFormat">setBlockCharFormat</a>().</p>
<h3 class="fn"><a name="mergeBlockFormat" />QTextCursor.mergeBlockFormat (<i>self</i>, <a href="qtextblockformat.html">QTextBlockFormat</a> <i>modifier</i>)</h3><p>Modifies the block format of the current block (or all blocks
that are contained in the selection) with the block format
specified by <i>modifier</i>.</p>
<p><b>See also</b> <a href="qtextcursor.html#setBlockFormat">setBlockFormat</a>() and <a href="qtextcursor.html#blockFormat">blockFormat</a>().</p>
<h3 class="fn"><a name="mergeCharFormat" />QTextCursor.mergeCharFormat (<i>self</i>, <a href="qtextcharformat.html">QTextCharFormat</a> <i>modifier</i>)</h3><p>Merges the cursor's current character format with the properties
described by format <i>modifier</i>. If the cursor has a selection,
this function applies all the properties set in <i>modifier</i> to
all the character formats that are part of the selection.</p>
<p><b>See also</b> <a href="qtextcursor.html#hasSelection">hasSelection</a>() and <a href="qtextcursor.html#setCharFormat">setCharFormat</a>().</p>
<h3 class="fn"><a name="movePosition" />bool QTextCursor.movePosition (<i>self</i>, <a href="qtextcursor.html#MoveOperation-enum">MoveOperation</a> <i>op</i>, <a href="qtextcursor.html#MoveMode-enum">MoveMode</a> <i>mode</i> = QTextCursor.MoveAnchor, int <i>n</i> = 1)</h3><p>Moves the cursor by performing the given <i>operation</i>
<i>n</i> times, using the specified <i>mode</i>, and returns true
if all operations were completed successfully; otherwise returns
false.</p>
<p>For example, if this function is repeatedly used to seek to the
end of the next word, it will eventually fail when the end of the
document is reached.</p>
<p>By default, the move operation is performed once (<i>n</i> =
1).</p>
<p>If <i>mode</i> is <tt>KeepAnchor</tt>, 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.</p>
<p><b>See also</b> <a href="qtextcursor.html#setVisualNavigation">setVisualNavigation</a>().</p>
<h3 class="fn"><a name="position" />int QTextCursor.position (<i>self</i>)</h3><p>Returns the absolute position of the cursor within the document.
The cursor is positioned between characters.</p>
<p><b>See also</b> <a href="qtextcursor.html#setPosition">setPosition</a>(), <a href="qtextcursor.html#movePosition">movePosition</a>(), <a href="qtextcursor.html#anchor">anchor</a>(), and <a href="qtextcursor.html#positionInBlock">positionInBlock</a>().</p>
<h3 class="fn"><a name="positionInBlock" />int QTextCursor.positionInBlock (<i>self</i>)</h3><p>Returns the relative position of the cursor within the block.
The cursor is positioned between characters.</p>
<p>This is equivalent to <tt>position() -
block().position()</tt>.</p>
<p>This function was introduced in Qt 4.7.</p>
<p><b>See also</b> <a href="qtextcursor.html#position">position</a>().</p>
<h3 class="fn"><a name="removeSelectedText" />QTextCursor.removeSelectedText (<i>self</i>)</h3><p>If there is a selection, its content is deleted; otherwise does
nothing.</p>
<p><b>See also</b> <a href="qtextcursor.html#hasSelection">hasSelection</a>().</p>
<h3 class="fn"><a name="select" />QTextCursor.select (<i>self</i>, <a href="qtextcursor.html#SelectionType-enum">SelectionType</a> <i>selection</i>)</h3><p>Selects text in the document according to the given
<i>selection</i>.</p>
<h3 class="fn"><a name="selectedTableCells" />(int <i>firstRow</i>, int <i>numRows</i>, int <i>firstColumn</i>, int <i>numColumns</i>) QTextCursor.selectedTableCells (<i>self</i>)</h3><p>If the selection spans over table cells, <i>firstRow</i> is
populated with the number of the first row in the selection,
<i>firstColumn</i> with the number of the first column in the
selection, and <i>numRows</i> and <i>numColumns</i> with the number
of rows and columns in the selection. If the selection does not
span any table cells the results are harmless but undefined.</p>
<h3 class="fn"><a name="selectedText" />QString QTextCursor.selectedText (<i>self</i>)</h3><p>Returns the current selection's text (which may be empty). This
only returns the text, with no rich text formatting information. If
you want a document fragment (i.e. formatted rich text) use
<a href="qtextcursor.html#selection">selection</a>() instead.</p>
<p><b>Note:</b> If the selection obtained from an editor spans a
line break, the text will contain a Unicode U+2029 paragraph
separator character instead of a newline <tt>\n</tt> character. Use
<a href="qstring.html#replace">QString.replace</a>() to replace
these characters with newlines.</p>
<h3 class="fn"><a name="selection" /><a href="qtextdocumentfragment.html">QTextDocumentFragment</a> QTextCursor.selection (<i>self</i>)</h3><p>Returns the current selection (which may be empty) with all its
formatting information. If you just want the selected text (i.e.
plain text) use <a href="qtextcursor.html#selectedText">selectedText</a>() instead.</p>
<p><b>Note:</b> Unlike <a href="qtextdocumentfragment.html#toPlainText">QTextDocumentFragment.toPlainText</a>(),
<a href="qtextcursor.html#selectedText">selectedText</a>() may
include special unicode characters such as <a href="qchar.html#SpecialCharacter-enum">QChar.ParagraphSeparator</a>.</p>
<p><b>See also</b> <a href="qtextdocumentfragment.html#toPlainText">QTextDocumentFragment.toPlainText</a>().</p>
<h3 class="fn"><a name="selectionEnd" />int QTextCursor.selectionEnd (<i>self</i>)</h3><p>Returns the end of the selection or <a href="qtextcursor.html#position">position</a>() if the cursor doesn't
have a selection.</p>
<p><b>See also</b> <a href="qtextcursor.html#selectionStart">selectionStart</a>(), <a href="qtextcursor.html#position">position</a>(), and <a href="qtextcursor.html#anchor">anchor</a>().</p>
<h3 class="fn"><a name="selectionStart" />int QTextCursor.selectionStart (<i>self</i>)</h3><p>Returns the start of the selection or <a href="qtextcursor.html#position">position</a>() if the cursor doesn't
have a selection.</p>
<p><b>See also</b> <a href="qtextcursor.html#selectionEnd">selectionEnd</a>(), <a href="qtextcursor.html#position">position</a>(), and <a href="qtextcursor.html#anchor">anchor</a>().</p>
<h3 class="fn"><a name="setBlockCharFormat" />QTextCursor.setBlockCharFormat (<i>self</i>, <a href="qtextcharformat.html">QTextCharFormat</a> <i>format</i>)</h3><p>Sets the block char format of the current block (or all blocks
that are contained in the selection) to <i>format</i>.</p>
<p><b>See also</b> <a href="qtextcursor.html#blockCharFormat">blockCharFormat</a>().</p>
<h3 class="fn"><a name="setBlockFormat" />QTextCursor.setBlockFormat (<i>self</i>, <a href="qtextblockformat.html">QTextBlockFormat</a> <i>format</i>)</h3><p>Sets the block format of the current block (or all blocks that
are contained in the selection) to <i>format</i>.</p>
<p><b>See also</b> <a href="qtextcursor.html#blockFormat">blockFormat</a>() and <a href="qtextcursor.html#mergeBlockFormat">mergeBlockFormat</a>().</p>
<h3 class="fn"><a name="setCharFormat" />QTextCursor.setCharFormat (<i>self</i>, <a href="qtextcharformat.html">QTextCharFormat</a> <i>format</i>)</h3><p>Sets the cursor's current character format to the given
<i>format</i>. If the cursor has a selection, the given
<i>format</i> is applied to the current selection.</p>
<p><b>See also</b> <a href="qtextcursor.html#charFormat">charFormat</a>(), <a href="qtextcursor.html#hasSelection">hasSelection</a>(), and <a href="qtextcursor.html#mergeCharFormat">mergeCharFormat</a>().</p>
<h3 class="fn"><a name="setKeepPositionOnInsert" />QTextCursor.setKeepPositionOnInsert (<i>self</i>, bool <i>b</i>)</h3><p>Defines whether the cursor should keep its current position when
text gets inserted at the current position of the cursor.</p>
<p>If <i>b</i> is true, the cursor keeps its current position when
text gets inserted at the positing of the cursor. If <i>b</i> is
false, the cursor moves along with the inserted text.</p>
<p>The default is false.</p>
<p>Note that a cursor always moves when text is inserted before the
current position of the cursor, and it always keeps its position
when text is inserted after the current position of the cursor.</p>
<p>This function was introduced in Qt 4.7.</p>
<p><b>See also</b> <a href="qtextcursor.html#keepPositionOnInsert">keepPositionOnInsert</a>().</p>
<h3 class="fn"><a name="setPosition" />QTextCursor.setPosition (<i>self</i>, int <i>pos</i>, <a href="qtextcursor.html#MoveMode-enum">MoveMode</a> <i>mode</i> = QTextCursor.MoveAnchor)</h3><p>Moves the cursor to the absolute position in the document
specified by <i>pos</i> using a <tt>MoveMode</tt> specified by
<i>m</i>. The cursor is positioned between characters.</p>
<p><b>See also</b> <a href="qtextcursor.html#position">position</a>(), <a href="qtextcursor.html#movePosition">movePosition</a>(), and <a href="qtextcursor.html#anchor">anchor</a>().</p>
<h3 class="fn"><a name="setVerticalMovementX" />QTextCursor.setVerticalMovementX (<i>self</i>, int <i>x</i>)</h3><p>Sets the visual x position for vertical cursor movements to
<i>x</i>.</p>
<p>The vertical movement x position is cleared automatically when
the cursor moves horizontally, and kept unchanged when the cursor
moves vertically. The mechanism allows the cursor to move up and
down on a visually straight line with proportional fonts, and to
gently "jump" over short lines.</p>
<p>A value of -1 indicates no predefined x position. It will then
be set automatically the next time the cursor moves up or down.</p>
<p>This function was introduced in Qt 4.7.</p>
<p><b>See also</b> <a href="qtextcursor.html#verticalMovementX">verticalMovementX</a>().</p>
<h3 class="fn"><a name="setVisualNavigation" />QTextCursor.setVisualNavigation (<i>self</i>, bool <i>b</i>)</h3><p>Sets visual navigation to <i>b</i>.</p>
<p>Visual navigation means skipping over hidden text pragraphs. The
default is false.</p>
<p>This function was introduced in Qt 4.4.</p>
<p><b>See also</b> <a href="qtextcursor.html#visualNavigation">visualNavigation</a>() and
<a href="qtextcursor.html#movePosition">movePosition</a>().</p>
<h3 class="fn"><a name="verticalMovementX" />int QTextCursor.verticalMovementX (<i>self</i>)</h3><p>Returns the visual x position for vertical cursor movements.</p>
<p>A value of -1 indicates no predefined x position. It will then
be set automatically the next time the cursor moves up or down.</p>
<p>This function was introduced in Qt 4.7.</p>
<p><b>See also</b> <a href="qtextcursor.html#setVerticalMovementX">setVerticalMovementX</a>().</p>
<h3 class="fn"><a name="visualNavigation" />bool QTextCursor.visualNavigation (<i>self</i>)</h3><p>Returns true if the cursor does visual navigation; otherwise
returns false.</p>
<p>Visual navigation means skipping over hidden text pragraphs. The
default is false.</p>
<p>This function was introduced in Qt 4.4.</p>
<p><b>See also</b> <a href="qtextcursor.html#setVisualNavigation">setVisualNavigation</a>()
and <a href="qtextcursor.html#movePosition">movePosition</a>().</p>
<h3 class="fn"><a name="__eq__" />bool QTextCursor.__eq__ (<i>self</i>, <a href="qtextcursor.html">QTextCursor</a> <i>rhs</i>)</h3><h3 class="fn"><a name="__ge__" />bool QTextCursor.__ge__ (<i>self</i>, <a href="qtextcursor.html">QTextCursor</a> <i>rhs</i>)</h3><h3 class="fn"><a name="__gt__" />bool QTextCursor.__gt__ (<i>self</i>, <a href="qtextcursor.html">QTextCursor</a> <i>rhs</i>)</h3><h3 class="fn"><a name="__le__" />bool QTextCursor.__le__ (<i>self</i>, <a href="qtextcursor.html">QTextCursor</a> <i>rhs</i>)</h3><h3 class="fn"><a name="__lt__" />bool QTextCursor.__lt__ (<i>self</i>, <a href="qtextcursor.html">QTextCursor</a> <i>rhs</i>)</h3><h3 class="fn"><a name="__ne__" />bool QTextCursor.__ne__ (<i>self</i>, <a href="qtextcursor.html">QTextCursor</a> <i>rhs</i>)</h3><address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt 4.9.3 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt 4.8.2</td></tr></table></div></address></body></html>
|