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
5
votes
3 answers

Qt Text Edit with a fixed number of input lines

I have a Qt "Text Edit" widget in my Gui and this widget is used to log something. I add every line(s) this way: QString str; str = ... widget.textEdit_console->append(str); by this way the Text Edit height will increase more and more after each…
blackfox
  • 71
  • 1
  • 6
5
votes
1 answer

Get QTextEdit changes when textChanged() signal is emited

I have a QTextEdit and I connected the textChanged() slot to a signal. How can I find the changes when the signal is emitted. For example, I want to save the cursor position and the character written when I write something.
John Smith
  • 1,276
  • 4
  • 17
  • 35
5
votes
2 answers

QLineEdit::textEdited() equivalent in QTextEdit?

In QLineEdit, there is a textEdit() signal, which only emits if the user changes the text, but not when you call setText(), So what's the equivalent in QTextEdit? I only see a textChanged() signal, and the documentation states it is emitted whenever…
daisy
  • 22,498
  • 29
  • 129
  • 265
5
votes
1 answer

QTextEdit::adjustSize() not working?

Setting text for QTextEdit: te->setPlainText(“Something”) ; te->adjustSize(); should wrap around “Something” only, instead the QTextEdit is expanding to its maximum Width-Height, can’t fix it.. When I select “Something” on run time, only…
Noob
  • 217
  • 1
  • 2
  • 10
5
votes
1 answer

Custom text (code) areas in QTextEdit

I am interested in creating a text object type (inheriting QTextObjectInterface) that behaves like a code area: distinctive background border fixed-width font editable content the instances need to be identifiable to code, so that content inside…
Nicu Tofan
  • 1,052
  • 14
  • 34
5
votes
2 answers

QTextEdit - get selection line numbers

I have the following code (implemented in the mouseReleaseEvent) to detect when the user has selected lines of text: QTextCursor cursor = this->textCursor(); int start = cursor.selectionStart(); int end = cursor.selectionEnd(); …
Johnny Pauling
  • 12,701
  • 18
  • 65
  • 108
4
votes
1 answer

Overriding keyPressEvent in QTextEdit subclass

I have the following example in Qt in which I try to override the keyPressEvent of a subclass of QTextEdit, but gives me a "multiple definition of txt::keyPressEvent(QKeyEvent*)" and I can't figure out why: //txt.h #ifndef TXT_H #define…
Nini Michaels
  • 341
  • 7
  • 17
4
votes
1 answer

qt: intercepting tab character in QTextEdit

I am writing a small editor. I would like to change default behaviour of QTextEdit, that inserts tabs when Tab is hit. Instead I would like to put 4 spaces. What is the recommended way of doing this? I though about subclassing keyPressedEvent, but…
gruszczy
  • 40,948
  • 31
  • 128
  • 181
4
votes
1 answer

Increase the bottom margin in QTextEdit

I need to make the scrollbar enabled even if the number of lines is less than the height of the QTextEdit, like in below pic I tried setDocumentMargin() but it makes margin in all directions (left, right, top, and bottom) So, is there a way to…
4
votes
1 answer

pyqt5 textedit delete lines as they move past specified line

I'd like to setup the PYQT Qtextedit widget and use it to monitor another applications activity log(like tail -f on Linux). Long term I worry about it running for too long and using a lot of ram with the text that builds up. Is it possible to set a…
sidnical
  • 421
  • 1
  • 6
  • 23
4
votes
2 answers

QTextEdit takes an increasing amount of time to draw the text

I am using a QTextEdit, and I update the text (specifically setHTML) at a 1Hz rate. Initially the setHtml method is fast (only a few ms); but after 12 hours of running, it takes 256 ms for setHTML to return, the data is a simple table with 5 columns…
Jmussemann
  • 51
  • 8
4
votes
1 answer

PyQt4: QTextEdit start in nth line

I have a popup that only contains a QTextEdit, it has a lot of text in it, a lot of lines. I want it to scroll to a certain line in the QTextEdit on show(). So that the line I want is at the top. Code snippet: editor = QtGui.QTextEdit() # fill the…
Bob Sacamano
  • 699
  • 15
  • 39
4
votes
3 answers

Qt: how to move textEdit cursor to specific col and row

I can get the current position in row and col via QTextCursor::blockNumber() and QTextCursor::positionInBlock(). My question is that how to move the cursor to the specific position with row and col. like setPosition(x,y) // The current cursor would…
loser5566
  • 117
  • 2
  • 8
4
votes
1 answer

What's a good way to display a lot of text in QT

I'm building an app that will read in a gcode file. Files range from a few KB to a few hundred MB (but that's rare). After a user selects a file, the program goes through it and reads it line by line. This doesn't take long at all. I want to…
Memnarch1113
  • 99
  • 1
  • 8
4
votes
2 answers

Pressing Tab in QTextEdit in Dialog - change behavior

I have QDialog that contains few buttons and a QTextEdit. after writing something in the QTextEdit, I press tab in order to get to one of the buttons, but when I pressing tab, a tab space is added to the QTextEdit. How can I change this behavior?
kakush
  • 3,334
  • 14
  • 47
  • 68