qtextedit

How to align QTextEdit text

六月ゝ 毕业季﹏ 提交于 2020-01-06 03:13:06
问题 How can I align this text? \t is not good. What I see (image) Expected result (image) 回答1: I had this problem once in the past. To solve the issue I used monospace font. To get everything aligned (fixed font width) I used these lines: // Use "monospaced" font: // ->insure left column alignment, as for the terminal // QFont font("monospace"); font.setPointSize(10); myQTextEdit->setCurrentFont(font); from my parent widget containing a QTextEdit child widget. 回答2: this line: QString str =

Line-Numbering of a textEdit in pyqt

ε祈祈猫儿з 提交于 2020-01-04 09:36:08
问题 I wish to number the lines in a textEdit in such a way that the line number do not get copied or cut where as the rest of the data which I dump in it can be accesed. 回答1: You'll need a separate widget on the side to display line numbers. You can find details here: http://harmattan-dev.nokia.com/docs/library/html/qt4/widgets-codeeditor.html 来源: https://stackoverflow.com/questions/17424032/line-numbering-of-a-textedit-in-pyqt

How to set the PlaceHolderText for QTextEdit

假装没事ソ 提交于 2020-01-03 17:43:30
问题 I just want to set a PlaceHolderText for a QTextEdit . I know how to set it for a QLineEdit . There is a Property, setPlaceHolderText for QLineEdit. But this Property is not available for QTextEdit. Please give your valuable suggestions to solve this. 回答1: Use setTextCursor(QTextCursor&) function of QTextEdit. Use the following logic. QTextCursor textCursor; textCursor.setPosistion(0, QTextCursor::MoveAnchor); textedit->setTextCursor( textCursor ); 回答2: I was able to do this by subclassing

How to set the PlaceHolderText for QTextEdit

谁说我不能喝 提交于 2020-01-03 17:43:07
问题 I just want to set a PlaceHolderText for a QTextEdit . I know how to set it for a QLineEdit . There is a Property, setPlaceHolderText for QLineEdit. But this Property is not available for QTextEdit. Please give your valuable suggestions to solve this. 回答1: Use setTextCursor(QTextCursor&) function of QTextEdit. Use the following logic. QTextCursor textCursor; textCursor.setPosistion(0, QTextCursor::MoveAnchor); textedit->setTextCursor( textCursor ); 回答2: I was able to do this by subclassing

qtextedit change font

断了今生、忘了曾经 提交于 2020-01-03 06:37:10
问题 I am using QTextEdit in my project I want to change the Font of the text edit area when user clicks on a button. I am using QTextEdit::setCurrentFont() function for this purpose. But, in order to change the font, the user has to first select some text in the textedit area. The font of the whole textedit changes only after selecting some text and then changing the font. Is there any way to avoid having to select the text to change font? I want the font to change even if the user has not

Qt Clear Undo History in a QTextEdit/QPlainTextEdit?

五迷三道 提交于 2020-01-02 04:54:09
问题 I have a QPlainTextEdit and I'm building a progress dialog for it when opening large files. Rather than using setText, I want to add one line of text at a time by using QTextCursor.insertText. The problem is that when I do it this way, I can undo each line that was added... is there a way to clear the undo history? 回答1: Use QTextDocument::clearUndoRedoStacks. Code: editor->document()->clearUndoRedoStacks(); // default clears both See docs if you want to clear just undo. Also, it's good idea

QTextEdit as a child node for QTreeWidgetItem?

自闭症网瘾萝莉.ら 提交于 2019-12-25 07:28:26
问题 Is it possible to add a QTextEdit as a child in QTreeWidget? Here is my code we can create a QTreeWidget and add the columns: self.treetext = QtGui.QTreeWidget(self.dockWidgetContents_2) self.treetext.setObjectName(_fromUtf8("treetext")) self.verticalLayout_2.addWidget(self.treetext) self.treetext.setGeometry(QtCore.QRect(20, 10, 261, 241)) item_0 = QtGui.QTreeWidgetItem(self.treetext) item_1 = QtGui.QTreeWidgetItem(item_0) item_1 = QtGui.QTreeWidgetItem(item_0) item_1 = QtGui.QTreeWidgetItem

PyQt5: How to scroll text in QTextEdit automatically (animational effect)?

回眸只為那壹抹淺笑 提交于 2019-12-24 17:54:50
问题 I would like to ask how to make the text in QTextEdit scoll, to achieve an animational effect. The animational effect should be something like what in the video shows: https://www.youtube.com/watch?v=MyeuGdXv4XM With PyQt I want to get this effect: The text should be scolled automatically at a speed of 2 lines/second downwards, till it reaches the end and stops. In my code below, when the button is clicked, the text is shown in QTextEdit-Widget. The text is very long, so that the scroll bar

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

限于喜欢 提交于 2019-12-24 01:54:46
问题 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 problems when using various programs (regardless of the language they were written in). How does one deal with this problem? The behavior I want when a new line is added to the text: if the scrollbar is at the bottom, scroll down automatically. if the

How do I get the currently visible text from a QTextEdit or QPlainTextEdit widget?

↘锁芯ラ 提交于 2019-12-23 10:11:41
问题 It seems like this would be a common thing to do, but I can't find how. I have a QTextEdit or QPlainTextEdit widget with a bunch of text. Enough that scrolling is necessary. I want another widget to give some information about the currently visible text. To do this, I need to know when the visible text changes what's the text? I see that QPlainTextEdit has the method firstVisibleBlock, but it's protected. This tells me that it's not really something I should be using in my application. I