schall_l
8th July 2009, 08:35
Hello,
I have followed the document from http://doc.qtsoftware.com/4.5/richtext-html-subset.html to set some css style when declaring an html string that will later on be used in a QTextEdit widget.
Some of the css style are working, while others have not effect.
In my example:
background is working
color is working
align is NOT working
font-size is NOT working
Did I miss something?
#include <QtGui>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QString html_sequence = QString(" \
<html> \
<head> \
<style type=text/css> \
body { background: #ffffff; color: black; } \
.title { background: #f0f0f0; align: center; } \
.subtitle { font-size: 8px; color: red;} \
.small-subtitle { font-size: 6px; color: blue; } \
</style> \
</head> \
\
<body> \
<h1 class=title>Title without subtitle<br /></h1> \
<h1 class=title>Title with subtitle<br /><span class=subtitle>This is the subtitle</span></h1> \
<h1 class=title>Title with small subtitle<br /><span class=small-subtitle>This is the small subtitle</span></h1> \
</body> \
</html> \
");
QTextEdit test(html_sequence);
test.show();
return app.exec();
}
I have followed the document from http://doc.qtsoftware.com/4.5/richtext-html-subset.html to set some css style when declaring an html string that will later on be used in a QTextEdit widget.
Some of the css style are working, while others have not effect.
In my example:
background is working
color is working
align is NOT working
font-size is NOT working
Did I miss something?
#include <QtGui>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QString html_sequence = QString(" \
<html> \
<head> \
<style type=text/css> \
body { background: #ffffff; color: black; } \
.title { background: #f0f0f0; align: center; } \
.subtitle { font-size: 8px; color: red;} \
.small-subtitle { font-size: 6px; color: blue; } \
</style> \
</head> \
\
<body> \
<h1 class=title>Title without subtitle<br /></h1> \
<h1 class=title>Title with subtitle<br /><span class=subtitle>This is the subtitle</span></h1> \
<h1 class=title>Title with small subtitle<br /><span class=small-subtitle>This is the small subtitle</span></h1> \
</body> \
</html> \
");
QTextEdit test(html_sequence);
test.show();
return app.exec();
}