qtextedit

How add text without new line in QTextEdit PyQt4 Python 2.7?

妖精的绣舞 提交于 2019-12-11 04:57:00
问题 I have problem with add text without new line in QTextEdit. I must add the value of variable "self.value" and next text ", word" It's my code: import sys from PyQt4.QtCore import * from PyQt4.QtGui import * class Text(QWidget): def __init__(self, parent = None): super(Text, self).__init__(parent) self.value = 5 layout = QHBoxLayout() self.text_edit = QTextEdit() self.text_edit.append(str(self.value)) self.text_edit.append(", word") layout.addWidget(self.text_edit) self.setLayout(layout) self

QTextEdit::setTextFormat(Qt::LogText) does not exist anymore, what else can I use to log?

≡放荡痞女 提交于 2019-12-10 14:22:27
问题 I need a text logger in my C++ application, QTextEdit used to have this feature until Qt 3.3 but unfortunately it has been removed. Is there an alternative that I could use? 回答1: Two options: You could simply use QTextEdit::setReadOnly(true) , the old Qt::LogText flag basically just put the QTextEdit in plain-text read-only mode. Or use Q3TextEdit , the Qt4 compatibility class for the old Qt3 QTextEdit . 回答2: It seems to me that QPlainTextEdit is what you are looking for. It is optimized for

Piping output of a QIODevice to a QTextEdit

社会主义新天地 提交于 2019-12-10 11:57:58
问题 How to I make the output of a QIODevice ( QProcess , specifically) go into a QTextEdit in real time? 回答1: Connect the QProcess::readyRead signal to a slot that then reads from the QProcess using QProcess::readAllStandardOutput and writes the text to the QTextEdit with QTextEdit::append. 回答2: Write own class! Header: class MyProcess : public QProcess { Q_OBJECT ... protected: virtual qint64 readData( char * data, qint64 maxlen ); ... }; Source: qint64 MyProcess::readData( char * data, qint64

How to redirect print result from python shell into qtextedit pyqt?

半世苍凉 提交于 2019-12-08 12:18:00
问题 I want my output to appear in my pyqt textedit not python shell after clicking a pushbutton. I am not familiar with subprocess or stdout stuff and not even sure if this will involve them. Need some help here. Here is part of my code: self.textEdit = QtGui.QTextEdit(Dialog) self.textEdit.setGeometry(QtCore.QRect(20, 200, 431, 241)) self.textEdit.setObjectName(_fromUtf8("textEdit")) def readI2C(self): data = i2c.read_byte(0x50) return data self.textEdit.setText(data) This code does not print

Draw vertical lines on QTextEdit in PyQt

≡放荡痞女 提交于 2019-12-08 07:04:10
问题 I am trying to develop a GUI that contains a QTextEdit widget. When the gui loads, it pulls in data from a file where the data is in columns of fixed widths. I want the user to be able to click at various points in the QTextEdit widget, to mark the positions where new columns start, and I want vertical lines to be drawn on the widget at those positions, to show the columns. In my GUI init () method I had the following line to intercept the paintEvent from the text widget: self.mytextviewer

Clickable hyperlink in QTextEdit

寵の児 提交于 2019-12-07 00:25:03
问题 I want to use QTextEdit (in read-only mode) to show a clickable hyperlink, I used to do QTextEdit *textEdit = new QTextEdit; QTextCursor cursor(textEdit->document()); textEdit->setTextCursor(cursor); cursor->insertHtml("<a href=\"www.google.com\" >Google</a>"); textEdit->show(); this code will show Google as hyperlink but unable to click. And if I used QTextEdit *textEdit = new QTextEdit; QTextCursor cursor(textEdit->document()); textEdit->setTextCursor(cursor); QTextCharFormat linkFormat =

How to make right-to-left language (eg.Arabic) characters behave like left-to-right languages do in qt?

穿精又带淫゛_ 提交于 2019-12-06 22:10:38
Qt provides a powerful adaptive way to deal with left-to-right languages and right-to-left languages texts.But I encounter my problems dealing with my goals. Picture No.1 What I want to get Picture No.2 What I got when paste to my QTextEdit based widget what picture no.1 shows Picture No.3 What I got when I set text-direction to left-to-right as shown below: QTextDocument *doc = ui->textEdit->document(); QTextOption textOption = doc->defaultTextOption(); textOption.setTextDirection(Qt::LeftToRight); doc->setDefaultTextOption(textOption); ui->textEdit->setDocument(doc); Making it left-to-right

How to change row height in QTextTable

喜欢而已 提交于 2019-12-06 18:11:24
问题 I'm writing the complicated rich text editor, derived from QTextEdit class. It must be able to insert, resize, and apply various formatting to embedded tables. I found function for setup column widths (setColumnWidthConstraints). But there is no one to change _rows_ heights . Is there any way to achieve this? Example code: void CustomTextEdit::insertTable (int rows_cnt, int columns_cnt) { QTextCursor cursor = textCursor (); QTextTableFormat table_format; table_format.setCellPadding (5); //

Connecting multiple signals to a single slot in Qt

♀尐吖头ヾ 提交于 2019-12-06 10:11:53
问题 I'm trying to keep track of the textChanged() signal on for handful of QTextEdits. I want to do the same thing regardless of the text edit emitting the signal: uncheck its associated checkbox in a QListWidget if it becomes empty and leave it checked otherwise. The function I have so for is as follows: void MainWindow::changed() { QString tempStr = ui->hNMRedit->toPlainText(); if(tempStr != "") { ui->checkList->item(0)->setCheckState(Qt::Checked); } else { ui->checkList->item(0)->setCheckState

Qt Clear Undo History in a QTextEdit/QPlainTextEdit?

喜你入骨 提交于 2019-12-05 17:20:55
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? Use QTextDocument::clearUndoRedoStacks . Code: editor->document()->clearUndoRedoStacks(); // default clears both See docs if you want to clear just undo. Also, it's good idea to read docs of QTextDocument (and QTextCursor) when working with the editor widgets. Lots of functionality