[Qt-interest] QTextEdit and html/css problem
Philippe Fremy
phil at freehackers.org
Thu Mar 26 17:24:44 CET 2009
Hi,
I have a bug/problem with Qt TextEdit.
I am trying to display new events occuring in a textedit in the form of
one line with a different background (the title) along the whole line,
and then some text.
I want the following output:
[] = different background
[ Event1 Title ]
bla
bla
bla
[ Event2 Title ]
bla
bla
bla
I am using the following html code:
QString htmlText =
"<p style=\"background-color:#eaf098; color:#455064;
font-size:10px\">Coucou</p> "
"<p style=\"color:#455064; font-size:12px\">Coucou</p> "
;
However, I am getting this:
[ Event1 Title ]
bla
bla
bla
[ Event2 Title ]
bla
bla
bla
The code is here :
#include "mainwindow.h"
#include "ui_mainwindow.h"
QString htmlText =
"<p style=\"background-color:#eaf098; color:#455064;
font-size:10px\">Coucou</p> "
"<p style=\"color:#455064; font-size:12px\">Coucou</p> "
;
// #define SHOW_BUGGY_TEXTEDIT false
#define SHOW_BUGGY_TEXTEDIT true
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindowClass)
{
ui->setupUi(this);
if (SHOW_BUGGY_TEXTEDIT) {
ui->textEdit->append( htmlText );
ui->textEdit->append( htmlText );
} else {
ui->textEdit->setHtml( htmlText + htmlText );
}
}
By changing the SHOW_BUGGY_TEXTEDIT, I get either the correct or the bad
behavior. So, setting the whole HTML makes QTextEdit react differently
than appending the html !
Any idea how I can get QTextEdit to do what I want ?
cheers,
Philippe
More information about the Qt-interest-old
mailing list