Hello,
i have been playing around with QHtmlDocument with no luck regarding Lykurg's reply. i am still able to change some of the CSS properties, but not all of them work (Colors are fine now, but list-style and float / positions aren't taken into account). The code i am now using to style up my text is as follows:
// Prepare HTML document.
// Set up stylesheet on slip summary widget.
QFile fStyle
(":/Resources/Stylesheets/SlipSummary.css");
fStyle.
open(QIODevice::ReadOnly|QIODevice
::Text);
fStyle.close();
_slipSummaryDoc
->addResource
(QTextDocument::StyleSheetResource,
QUrl("SlipSummary.css"), css
);
// Set document.
_ui.txtSlipSummary->setDocument(_slipSummaryDoc);
_slipSummaryDoc
->setHtml
(QString("<html><head><link rel='stylesheet' type='text/css' href='SlipSummary.css'></head><body>%1</body></html>").
arg(_documents
->htmlSummary
()));
// Prepare HTML document.
_slipSummaryDoc = new QTextDocument();
// Set up stylesheet on slip summary widget.
QFile fStyle (":/Resources/Stylesheets/SlipSummary.css");
fStyle.open(QIODevice::ReadOnly|QIODevice::Text);
QString css = fStyle.readAll();
fStyle.close();
_slipSummaryDoc->addResource(QTextDocument::StyleSheetResource, QUrl("SlipSummary.css"), css);
// Set document.
_ui.txtSlipSummary->setDocument(_slipSummaryDoc);
_slipSummaryDoc->setHtml(QString("<html><head><link rel='stylesheet' type='text/css' href='SlipSummary.css'></head><body>%1</body></html>").arg(_documents->htmlSummary()));
To copy to clipboard, switch view to plain text mode
The CSS style looks like this (Although it's really becoming a sandbox that has changed upon each test i've made):
* {
color: #222;
font-size: 10px;
font-weight: normal;
margin: 0;
padding: 0;
list-style: none;
text-indent: 0;
}
h1 {
color: #555;
font-size: 12px;
font-weight: bold;
}
h2 {
color: #444;
font-size: 11px;
font-weight: bold;
}
h3 {
color: #333;
font-size: 10px;
font-weight: bold;
}
ul, li {
list-style: none;
margin: 0;
padding: 0;
text-indent: 0;
}
span.amount {
float: right;
width: 60px;
margin: 0;
padding: 0;
text-align: right;
}
* {
color: #222;
font-size: 10px;
font-weight: normal;
margin: 0;
padding: 0;
list-style: none;
text-indent: 0;
}
h1 {
color: #555;
font-size: 12px;
font-weight: bold;
}
h2 {
color: #444;
font-size: 11px;
font-weight: bold;
}
h3 {
color: #333;
font-size: 10px;
font-weight: bold;
}
ul, li {
list-style: none;
margin: 0;
padding: 0;
text-indent: 0;
}
span.amount {
float: right;
width: 60px;
margin: 0;
padding: 0;
text-align: right;
}
To copy to clipboard, switch view to plain text mode
[edit]Oh and here is the generated HTML code being inserted:
<h2>4 Invoices<span class='amount'>$30.42</span></h2>
<h3>2 Utility<span class='amount'>$0.00</span></h3>
<ul>
<li>2 Energy<span class='amount'>$0.00</span></li>
</ul>
<h3>2 Car<span class='amount'>$30.42</span></h3>
<ul>
<li>1 Gas<span class='amount'>$8.50</span></li>
<li>1 Repairs<span class='amount'>$8.10</span></li>
</ul>
<h2>4 Invoices<span class='amount'>$30.42</span></h2>
<h3>2 Utility<span class='amount'>$0.00</span></h3>
<ul>
<li>2 Energy<span class='amount'>$0.00</span></li>
</ul>
<h3>2 Car<span class='amount'>$30.42</span></h3>
<ul>
<li>1 Gas<span class='amount'>$8.50</span></li>
<li>1 Repairs<span class='amount'>$8.10</span></li>
</ul>
To copy to clipboard, switch view to plain text mode
[/edit]
Again, thank you for any kind help you may provide!
Pierre.
Bookmarks