Hi! First of all - sorry for my English, I'm trying to do my best.
I want to make the report (and print it) with quite complex table. Last row of my table must be painted in part, i.e. part of cells shouldn't be painted. Something like that:
qqq.JPG
In HTML terms it looks like that (very garbage code, just explain my idea):
<table cellspacing=0 style="border-collapse: collapse">
<tr><td style='border: 1px solid black'>1</td>
<td style='border: 1px solid black'>2</td>
<td style='border: 1px solid black'>3</td></tr>
<tr><td style='border: 1px solid black'>One</td>
<td style='border: 1px solid black'>Two</td>
<td style='border: 1px solid black'>Three</td></tr>
<tr><td style='border-width: 1 0 0; border-style: solid; border-color: black'></td>
<td style='border-width: 1 0 0; border-style: solid; border-color: black'></td>
<td style='border: 1px solid black'>Finish</td></tr>
</table>
<table cellspacing=0 style="border-collapse: collapse">
<tr><td style='border: 1px solid black'>1</td>
<td style='border: 1px solid black'>2</td>
<td style='border: 1px solid black'>3</td></tr>
<tr><td style='border: 1px solid black'>One</td>
<td style='border: 1px solid black'>Two</td>
<td style='border: 1px solid black'>Three</td></tr>
<tr><td style='border-width: 1 0 0; border-style: solid; border-color: black'></td>
<td style='border-width: 1 0 0; border-style: solid; border-color: black'></td>
<td style='border: 1px solid black'>Finish</td></tr>
</table>
To copy to clipboard, switch view to plain text mode
I'm using QTextDocument for my task. But neither setHtml() or QTextCursor (rather QTextTable) doesn't support styles for particular tables, only for the whole table! My attemps (using html, QTextCursor gives about the same result):
1) if set border style to the whole table, we get proper borders (a bit of thick, but that's other question):
html += "<table cellspacing=0 cellpadding = 2 style='border-width: 1px; border-style: solid; border-color: #000000'>";
html += "<tr>";
html += "<td>1</td>";
html += "<td>2</td>";
html += "<td>3</td>";
html += "</tr>";
html += "<tr>";
html += "<td>One</td>";
html += "<td>Two</td>";
html += "<td>Three</td>";
html += "</tr>";
html += "<tr>";
html += "<td></td>";
html += "<td></td>";
html += "<td>Finish</td>";
html += "</tr>";
html += "</table></body></html>";
page->setHtml(html);
QString html = "<html><body>";
html += "<table cellspacing=0 cellpadding = 2 style='border-width: 1px; border-style: solid; border-color: #000000'>";
html += "<tr>";
html += "<td>1</td>";
html += "<td>2</td>";
html += "<td>3</td>";
html += "</tr>";
html += "<tr>";
html += "<td>One</td>";
html += "<td>Two</td>";
html += "<td>Three</td>";
html += "</tr>";
html += "<tr>";
html += "<td></td>";
html += "<td></td>";
html += "<td>Finish</td>";
html += "</tr>";
html += "</table></body></html>";
page->setHtml(html);
To copy to clipboard, switch view to plain text mode
qq1.JPG
2) If try to make the same as with HTML (i.e. set border style for every cell), we get no borders at all.
html += "<table cellspacing=0 cellpadding=2'>";
html += "<tr>";
html += "<td style='border-width: 1px; border-style: solid; border-color: #000000'>1</td>";
html += "<td style='border-width: 1px; border-style: solid; border-color: #000000'>2</td>";
html += "<td style='border-width: 1px; border-style: solid; border-color: #000000'>3</td>";
html += "</tr>";
html += "<tr>";
html += "<td style='border-width: 1px; border-style: solid; border-color: #000000'>One</td>";
html += "<td style='border-width: 1px; border-style: solid; border-color: #000000'>Two</td>";
html += "<td style='border-width: 1px; border-style: solid; border-color: #000000'>Three</td>";
html += "</tr>";
html += "<tr>";
html += "<td style='border-style: none;'></td>";
html += "<td style='border-style: none;'></td>";
html += "<td style='border-width: 1px; border-style: solid; border-color: #000000'>Finish</td>";
html += "</tr>";
html += "</table></body></html>";
page->setHtml(html);
QString html = "<html><body>";
html += "<table cellspacing=0 cellpadding=2'>";
html += "<tr>";
html += "<td style='border-width: 1px; border-style: solid; border-color: #000000'>1</td>";
html += "<td style='border-width: 1px; border-style: solid; border-color: #000000'>2</td>";
html += "<td style='border-width: 1px; border-style: solid; border-color: #000000'>3</td>";
html += "</tr>";
html += "<tr>";
html += "<td style='border-width: 1px; border-style: solid; border-color: #000000'>One</td>";
html += "<td style='border-width: 1px; border-style: solid; border-color: #000000'>Two</td>";
html += "<td style='border-width: 1px; border-style: solid; border-color: #000000'>Three</td>";
html += "</tr>";
html += "<tr>";
html += "<td style='border-style: none;'></td>";
html += "<td style='border-style: none;'></td>";
html += "<td style='border-width: 1px; border-style: solid; border-color: #000000'>Finish</td>";
html += "</tr>";
html += "</table></body></html>";
page->setHtml(html);
To copy to clipboard, switch view to plain text mode
qq2.JPG
But I need the table at the beginning of my post. Any suggestions? Only crazy option comes to mint: stupidly draw each line with QPainter...
Bookmarks