Questions tagged [qtextedit]

QTextEdit is a class from the Qt Toolkit which provides a widget that is used to edit and display both plain and rich text. It is optimized to handle large documents and to respond quickly to user input.

The official Qt documentation can be found here for Qt 4.8 and here for Qt 5.

575 questions
4
votes
3 answers

How to resize an image in a QTextEdit?

How to click on the image, hold from a corner of it, and resize the image in the QTextEdit? Or at least how to get an image under cursor/that is selected in order to change width and hight?
Narek
  • 38,779
  • 79
  • 233
  • 389
4
votes
1 answer

How to format the selected text in a QTextEdit by pressing a button

I want to format a selected text in a QTextEdit by clicking a button. For axample I want to make it bold if it is not-bold, or not-bold if it is bold. Please help me with an example. EDIT: Actually I have found already a code - qt demo for text…
Narek
  • 38,779
  • 79
  • 233
  • 389
4
votes
3 answers

Display text from QLineEdit in a QTextEdit already containing some text and update it in real time

What is the procedure to make a text being written in a QLineEdit widget, dynamically display inside a QTextEdit that already contains some text? For example, let us say that a QLineEdit asks for a name where one writes "John". Is it possible to…
Meclassic
  • 209
  • 2
  • 5
4
votes
1 answer

How do I determine the height of a QTextDocument?

Given a specific width, I want to find out the height of a QTextDocument. In other words, if the QTextEdit that contains the QTextDocument is w wide, what is its minimum height h in order to fully display the document without the need for…
Tony the Pony
  • 40,327
  • 71
  • 187
  • 281
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
3 answers

Aligning text in QTextEdit?

If I have a QTextEdit box, how can I align different pieces of text within the box in different ways? For example, I would like to have one sentence be aligned-left, and the next sentence in the box be aligned-right. Is this possible? If not, how…
Kvass
  • 8,294
  • 12
  • 65
  • 108
4
votes
2 answers

PyQt or PySide: QTextEdit deselect all

I'm using PySide(PyQt is fine as well) and I want to deselect everything inside a QTextEdit. Selecting everything is very easy and it's done by self.textedit.selectAll(), but I can't find a simple way to deselect everything. Is there a…
Antoni4040
  • 2,297
  • 11
  • 44
  • 56
4
votes
1 answer

How to limit QTextEdit to accept a subset of all characters?

I need to make QTextEdit able to accept only numbers, spaces and line breaks (enter/return). How can I do it?
Ufx
  • 2,595
  • 12
  • 44
  • 83
4
votes
2 answers

Streaming to QTextEdit via QTextStream

I have often wanted to use QTextEdit as a quick means of displaying what is being written to a stream. That is, rather than writing to QTextStream out(stdout), I want to do something like: QTextEdit qte; QTextStream out(qte); I could do…
Moomin
  • 1,846
  • 5
  • 29
  • 47
4
votes
1 answer

Changing selection color using QTextCharFormat

I am writing simple editor, I use QTextEdit for text edit QSyntaxHighlighter to do syntax colouring. Style is aplied by QTextCharFormat. I know how to create simple styles like: keyword_format =…
vericule
  • 275
  • 3
  • 10
4
votes
1 answer

Save Contents of QTextEdit as *.pdf?

I am trying to save the contents of a Text Editor as a pdf file. The text Editor has been made using PyQt (i didn't make the text Editor), i got the code of the text editor from here. I have done some changes to the editor but that wont be a…
thecreator232
  • 2,145
  • 1
  • 36
  • 51
4
votes
1 answer

Getting only the visible text from a QTextEdit widget

I have been searching for a day and not found an answer to this. This thread How do I get the currently visible text from a QTextEdit or QPlainTextEdit widget? merely answers how to get ALL the text contained in the widget. In my situation, I have a…
Raj
  • 1,764
  • 2
  • 13
  • 14
4
votes
1 answer

QTextedit set anchor and scroll to it

How can I set an anchor in QTextEdit? There seems to be a method to scroll to an anchor, but not any method to set actually one. So I tried this, but it does not work. mTextEdit->setHtml("some html stuff"); mTextEdit->append("
Niklas
  • 23,674
  • 33
  • 131
  • 170
4
votes
1 answer

QTextEdit: scroll beyond last line

I display some rich text contents using a subclass of QTextEdit. Some editors - especially code editors & IDEs offer a possibility to scroll beyond the last line all the way until the last line gets to the top of the view. I'd love to be able to do…
kralyk
  • 4,249
  • 1
  • 32
  • 34
4
votes
2 answers

QTextEdit: scroll down automatically only if the scrollbar is at the bottom

There's a QTextEdit that displays quite a lot of text. It is NOT editable. Suppose I want to read something around the beginning, scroll up, but then a new line is added and the scrollbar automatically goes to the bottom. I experience similar…
Daniel
  • 305
  • 1
  • 4
  • 13