qtextedit

How do I determine the height of a QTextDocument?

烂漫一生 提交于 2019-12-14 02:08:54
问题 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 scrollbars? 回答1: Set the width for the QTextDocument object to your desired with and then call the function size().height(), this should return the height required for the width you have give it before. Have a look at the size() function documentation of

Making a QTextEdit capital

被刻印的时光 ゝ 提交于 2019-12-13 05:12:15
问题 I am trying to make all text in a QTextEdit capital, but currently am failing. This is my code and it does nothing. void MainWindow::on_actionCapital_triggered() { QTextCharFormat capital2; capital2.setFontCapitalization(QFont::AllUppercase); ui->textEdit->setCurrentCharFormat(capital2); } I am a java coder, so c++ is not my strong point I also tried the following code with no success: QFont font = ui->textEdit->font(); font.setCapitalization(QFont::AllUppercase); ui->textEdit->setFont(font);

Getting the bounding box of QTextEdit selection

為{幸葍}努か 提交于 2019-12-13 03:10:54
问题 I'm trying to get the bounding box of a series of text selections stored in a list. The bounding box is the smallest rectangle that can contain the whole selection. Each item in the list has a start and end point measured in characters from the beginning of the QTextEdit window and also a letter identifier. QTextEdit.cursorRect(cursor) should do this, but is producing nonsensical box dimensions: id: A -- PySide.QtCore.QRect(0, 0, 1, 10) id: B -- PySide.QtCore.QRect(0, 0, 1, 10) id: C --

Replacing QTextEdit bounding box with a line

梦想与她 提交于 2019-12-13 00:13:30
问题 This question is a slight modification of the bounding box example. I'm trying to understand how to draw simple shapes. I just want to replace the bounding box with a diagonal line from the upperLeft point to the lowerRight point. However, QLine() does not appear to have a show() method and viewport() has no addItem() method. So, I think the line is not being displayed. Here is my modification of the showBoxes method: def showLines(self): while self.boxes: self.boxes.pop() #self.boxes.pop()

Qt Python: QTextEdit - display input

ⅰ亾dé卋堺 提交于 2019-12-12 05:57:34
问题 I have a QTextEdit... it works with 'clear()' when a pushbutton calls 'CleanComments' to clean the input done by the user. Here is the code: def CleanComments(self): self.textEditInput.clear() def showInput(self): print "show input: %s" % self.textEditInput.show() def buildEditInput(self): self.textEditInput = QtGui.QTextEdit(self.boxForm) self.textEditInput.setGeometry(QtCore.QRect(10, 300, 500, 100)) The only problem is, that when 'showInput' is called to display the content on QTextEdit

How to implement QTextDocument serialization

拟墨画扇 提交于 2019-12-12 03:42:47
问题 This question I have asked before and just got answer that there is an open bug for this. But this is a really required feature and, I guess, each Qt programmer who programmes a more or less serious application, it is quite probable that there is used a QTextEdit and the data is inserted in QTextEdit is serialized and deserialized. Thus I consider this issue very importand and it can be useful for many Qt developers. So I have decided to discuss with good programmers how to implement operator

Aligning text using format in a QTextEdit in Python

烈酒焚心 提交于 2019-12-11 13:16:17
问题 I want to display text in a QTextEdit. I use the format() function to align the text and make it look like a clean table. Although I get a perfect result when displaying the text in the shell, the text doesn't seem to align in the QTextEdit, like if the width of a character varies. I mainly see the difference when the character "-" is present. >>> first_line = "{:<10} {:<3} - {:<20}".format("1234", "EUR", "Mrs Smith") >>> second_line = "{:<10} {:<3} - {:<20}".format("-45.62", "GBP", "M Doe")

Qt + QTextEdit content into QDomDocument

假装没事ソ 提交于 2019-12-11 11:39:15
问题 I'm having QTextEdit widget with large (XML) content in it, so I take the content using: document = textEdit->document(); How do I set it into a QDomDocument ? 回答1: Try this... QDomDocument *xmlDocument = new QDomDocument(); QString error; int errorLine = 0; int errorColumn = 0; bool docStatus = xmlDocument->setContent(textEdit->toPlainText()->toAscii(),&error,&errorLine,&errorColumn); It isn't tested. But hope it will work.. Check it out.. Edit: Alternatively give bool docStatus =

Inserting a child Item into a row of QTreeWidgetItems

孤人 提交于 2019-12-11 06:05:59
问题 I have setup my QTreeWidget such that each cell is filled with comboboxes, however I would like to create a text edit widget next to the selected combobox (or overwrite the existing combobox), depending on which combobox item the user has selected. I figured I could do this by adding the comboboxes parent as a property when its initially setup and then upon interaction with the combobox simply use setItemWidget to put a text edit Item in column after the selected combobox (using the same

Qt 5.8 QTextEdit Text Cursor Color Won't Change

本秂侑毒 提交于 2019-12-11 05:24:52
问题 I am trying to make the text cursor on a QTextEdit red (rgb(255,0,0)). Despite my best efforts, it continues to blink white. From what I've found, the Style Sheet "color" property is supposed to change the color of the cursor. Not sure what's wrong. My Code: textEntry = new QTextEdit(); textEntry->setFont(QFont("Electrolize", 9, 1)); textEntry->setMinimumHeight(25); textEntry->setMaximumHeight(25); textEntry->setLineWrapMode(QTextEdit::NoWrap); textEntry->setHorizontalScrollBarPolicy(Qt: