Questions tagged [qtextcursor]

The QTextCursor class offers an API to access and modify QTextDocuments. 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 QTextDocument and any selection that it has made.

QTextCursor behaves in the same was as a text cursor works in a normal text editor's user interface. It always points either between two symbols of the string, before the first symbol, or after the last symbol. It can also hold a text that was selected.

74 questions
14
votes
2 answers

Moving the cursor inside of QTextEdit

I have a form with a QTextEdit on it, which is called translationInput. I am trying to provide the editing functionality for the user. This QTextEdit will contain HTML-formatted text. I have a set of buttons, like "bold", "Italic", and so on, which…
SingerOfTheFall
  • 29,228
  • 8
  • 68
  • 105
7
votes
1 answer

Prevent a QTextEdit widget from scrolling when there is a selection

I've researched this extensively but haven't found a satisfactory solution yet: How do I append text at the end of QTextEdit widget without triggering a scroll to the bottom of the widget when either of these conditions is met: The user has…
François Beaune
  • 4,270
  • 7
  • 41
  • 65
6
votes
2 answers

How to change the fontsize for everything inside QTextEdit in PyQt4?

I have a QTextEdit widget whose contents are populated programmatically using QTextEdit.textCursor. My plan is to let the user view the populated information in the QTextEdit, edit the text if necessary, and later print to a PDF file using…
Chris Aung
  • 9,152
  • 33
  • 82
  • 127
5
votes
1 answer

How i get the position of textcursor in QWebView Editable

I I have an editable QWebView, and would like to get the position (QPoint) of TextCursor. I searched but could only find the position of the cursor (mouse pointer) webview-> cursor.pos (); and this position is not what I want. Anyone have any…
FelipeMac
  • 71
  • 7
4
votes
1 answer

QPlainTextEdit: different char format for part of text

after scanning several examples I didn't manage to solve this problem: I created a test for this having a simple MainWindow with a QPlainTextEdit containing some text. On a trigger I want a part of the text to be red and underlined. But that never…
Jazzco
  • 68
  • 5
4
votes
1 answer

Copying selected text with QTextCursor

These are the widgets that I have, self.recipient = QTextEdit(self) self.document = QTextDocument(self) self.recipient.setDocument(self.document) self.cursor = QTextCursor(self.document) and what I want to do is use the QTextCursor to copy the…
4
votes
1 answer

Why does cursor.clearselection() does not work in this example?

I am trying to create a button which underlines the selected text of my QTextEdit instance. In the constructor, I am activating the cursor and setting a bool variable for the setFontUnderline method used later. QTextCursor cursor1 =…
steve
  • 123
  • 1
  • 14
4
votes
2 answers

Selecting a piece of text using QTextCursor

Having problems with selecting pieces of text using the Qt framework. For example if i have this document : "No time for rest". And i want to select "ime for r" and delete this piece of text from the document, how should i do it using QTextCursor?…
Zan
  • 290
  • 4
  • 17
3
votes
2 answers

How to make QTextCursor::WordUnderCursor include more characters or larger words

I'm trying to show a tooltip when the cursor is over a keyword in a text editor using: QTextCursor cursor = cursorForPosition(pos); cursor.select(QTextCursor::WordUnderCursor); This works well but the definition of a word does not fits my needs.…
JRR
  • 3,024
  • 2
  • 13
  • 37
3
votes
0 answers

How to make selected/highlighted text area bordered and semitransparent in Qt?

I am using Qt 5.3 and want to highlight and select the text of QTextEdit like Qt Creator. What I get is just simple highlight with blue background and white color. I am able to change the highlight background and text color with stylesheet and…
stackOverflow
  • 179
  • 1
  • 2
  • 18
3
votes
0 answers

How to keep QTextFrame/QTextBlock on one page?

Is there a way to keep the content of a QTextFrame or QTextBlock together on the same page? I don't want to insert a page break if there is still enough space for the content on the current page, but if not, all content should move together to the…
rmweiss
  • 716
  • 1
  • 6
  • 16
3
votes
1 answer

QPlainTextEdit - searches the document to the end and again from the beginning

I want to search in QPlainTextEdit for a string from the current cursor to the end. If nothing is found I want to continue searching from the start. Only in this stage, if nothing is found, a message will appear. This is the code: void…
Junior
  • 507
  • 5
  • 19
3
votes
0 answers

Vertical Text in QTextEdit

I need to have vertical text (direction - from bottom to top) in QTextEdit. The most similar solution I implemented is a replacing horizontal text block with rotated picture (screenshot of original text block) when user presses "rotate" button. But…
tmporaries
  • 1,523
  • 8
  • 25
  • 39
3
votes
1 answer

QLineEdit cursor moves to end after textChanged() or commitData()

I have a QTableView with one column that uses a QLineEdit as its editor delegate, and other columns that need to update dynamically as the user types into the QLineEdit (e.g. one of the columns contains the length of the text typed in the QLineEdit…
Jettoblack
  • 125
  • 3
  • 8
3
votes
1 answer

Qt ignores CSS in QTextDocument

Here is a small snippet of my code, I don't know why but Qt is ignoring the css. QTextDocument *mTextDocument = new QTextDocument(0); QTextEdit *textEdit = new…
Jaydeep Solanki
  • 2,895
  • 5
  • 36
  • 50
1
2 3 4 5