qtextedit

Print out python console output to Qtextedit

馋奶兔 提交于 2019-11-28 09:34:15
I have the output like this, when I press the button ['VERSION', 'ROMMON', 'HOSTNAME', 'UPTIME', 'RUNNING_IMAGE', 'HARDWARE', 'SERIAL', 'CONFIG_REGISTER'] ['12.2(55)SE7', 'Bootstrap', 'Revo-Solusindo-01', '1 hour, 27 minutes', 'c2960s-universalk9-mz.122-55.SE7.bin', ['WS-C2960S-24PD-L'], ['FOC1644Z129'], '0xF'] Write 1 records ['FAN', 'TEMPERATURE', 'TEMPERATURE_VALUE', 'TEMPERATURE_STATE', 'YELLOW_THRESHOLD', 'RED_THRESHOLD', 'POWER', 'RPS'] ['OK', 'OK', '33', 'GREEN', '54', '64', '', ''] Write 1 records ['TOTAL', 'FFREE'] ['57931776', '29178368'] ['524288', '523212'] Write 2 records [

How to serialize and deserialize rich text in QTextEdit?

我与影子孤独终老i 提交于 2019-11-28 09:07:04
问题 Say I have a structure like this: class AAA { BBB bb_member; double dbl_member; .................... } class BBB { int int_member; QString QStr_member; ................. QTextEdit m_textEdit; } And for AAA I define this operators: QDataStream &operator<<(QDataStream &out, const AAA &aa) { out << aa.bb_member << aa.dbl_member; return out; } QDataStream &operator>>(QDataStream &in, AAA &aa) { BBB bb_memb; double dbk_memb; in >> bb_memb >> dbk_memb; aa = AAA(bb_memb, dbk_memb); return in; } Then

Aligning text in QTextEdit?

随声附和 提交于 2019-11-28 06:12:03
问题 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 might I achieve this effect in Qt? 回答1: As documentation said: void QTextEdit::setAlignment(Qt::Alignment a) [slot] Sets the alignment of the current paragraph to a . Valid alignments are Qt::AlignLeft , Qt::AlignRight , Qt::AlignJustify and Qt:

QTextEdit with different text colors (Qt / C++)

∥☆過路亽.° 提交于 2019-11-27 21:07:26
I have a QTextEdit box that displays text, and I'd like to be able to set the text color for different lines of text in the same QTextEdit box. (i.e. line 1 might be red, line 2 might be black, etc.) Is this possible in a QTextEdit box? If not, what's the easiest way to get this behavior? Thanks. Use text formated as HTML, for example: textEdit->setHtml(text); where text , is a HTML formated text, contains with colored lines and etc. The ONLY thing that worked for me was html. Code snippet follows. QString line = "contains some text from somewhere ..." : : QTextCursor cursor = ui->messages-

QTextEdit with different text colors (Qt / C++)

六眼飞鱼酱① 提交于 2019-11-27 19:11:49
问题 I have a QTextEdit box that displays text, and I'd like to be able to set the text color for different lines of text in the same QTextEdit box. (i.e. line 1 might be red, line 2 might be black, etc.) Is this possible in a QTextEdit box? If not, what's the easiest way to get this behavior? Thanks. 回答1: Use text formated as HTML, for example: textEdit->setHtml(text); where text , is a HTML formated text, contains with colored lines and etc. 回答2: The ONLY thing that worked for me was html. Code

QTextEdit and colored bash-like output emulation

不问归期 提交于 2019-11-27 15:48:54
I have an escape sequences in a text, like char const * text = "\e[1;33m" "some colored text" "\e[0m"; Which usually printed in terminal. But I want to forward this text in QTextEdit . What is the simpliest way to make such text in QTextEdit colored? How to perform a filtering of escape sequences, i.e. how replace its with proper text formatting? I think there is QSyntaxHighlighter -aided solution possible, but I don't know what to do with escape sequences itself and how to hide they from the output. Finally, I found the approach (it is understood, that QTextEdit::setReadOnly(true) ): // based

QTextEdit vs QPlainTextEdit

半腔热情 提交于 2019-11-27 14:56:10
What's the difference between QTextEdit and QPlainTextEdit , why use one over the other? I'm coding a text editor as an exercice to learn Qt5, and now I'm wondering whether to use QTextEdit or QPlainTextEdit . So far I've only found out that you can display images in QTextEdit , but other than that they look somewhat identical to me. My text editor should support some basic syntax highlighting (probably using textChanged() signal), but that's pretty much as far as the requirements go. Google searches for "QTextEdit vs QPlainTextEdit" and "QTextEdit compared to QPlainTextEdit" didn't give me

Get text from qtextedit and assign it to a variable

。_饼干妹妹 提交于 2019-11-27 08:36:06
问题 When I try to get the text from the qtextedit created with PyQt5 Designer I get an error or "Python stop working" and the script stop automatically. I've tried multiple solutions but nothing works. I have to assign the text from the qtextedit to a variable, for check if the process run or no. That's the code generated by PyQt5: from PyQt5 import QtCore, QtGui, QtWidgets import psutil class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow

Center the Text of QTextEdit horizontally and vertically

怎甘沉沦 提交于 2019-11-27 07:25:39
问题 I want to center the text of my QTextEdit horizontally and vertically. I tried this, but it didn't work. m_myTextEdit = new QTextEdit("text edit", m_ui->centralWidget); m_myTextEdit->setGeometry(5, 50, 400, 250); m_myTextEdit->setReadOnly(true); m_myTextEdit->setAlignment(Qt::AlignCenter); Is there a opportunity to set it centered with a StyleSheet? 回答1: If you only need one line, you can use a QLineEdit instead: QLineEdit* lineEdit = new QLineEdit("centered text"); lineEdit->setAlignment(Qt:

Print out python console output to Qtextedit

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-27 03:00:53
问题 I have the output like this, when I press the button ['VERSION', 'ROMMON', 'HOSTNAME', 'UPTIME', 'RUNNING_IMAGE', 'HARDWARE', 'SERIAL', 'CONFIG_REGISTER'] ['12.2(55)SE7', 'Bootstrap', 'Revo-Solusindo-01', '1 hour, 27 minutes', 'c2960s-universalk9-mz.122-55.SE7.bin', ['WS-C2960S-24PD-L'], ['FOC1644Z129'], '0xF'] Write 1 records ['FAN', 'TEMPERATURE', 'TEMPERATURE_VALUE', 'TEMPERATURE_STATE', 'YELLOW_THRESHOLD', 'RED_THRESHOLD', 'POWER', 'RPS'] ['OK', 'OK', '33', 'GREEN', '54', '64', '', '']