How to combine multiple .html files together into one .html
I am using QTextEdit for this. Method insertHtml() helped. But this method works not as I imagine.
My file1.html is
Code:
<html>
<body>
<p>
<h2>title1</h2>
<ul>
<li>bla</li>
<li>bla</li>
</ul>
</p>
<br>
</body>
</html>
File2.html is
Code:
<html>
<body>
<p>
<h2>title2</h2>
<ul>
<li>blabla</li>
<li>blabla</li>
</ul>
</p>
<br>
</body>
</html>
My code is:
Code:
{
if (fileName1.endsWith(".html"))
textEdit->insertHtml(data1);
}
{
if (fileName2.endsWith(".html"))
textEdit->insertHtml(data2);
}
The problem is, the title of the file2 is always followed by the last bla, not aligned to the left of the file. If I insert a break line between these two parts:
Code:
textEdit->insertHtml("<hr>");
The line is beneath the file2's title. crazy!
Anyone can help? Or is there another way to complish this function?
Thanks.
Re: How to combine multiple .html files together into one .html
You probably should only insert a fragment, hot a whole HTML document including the html tags. Use QRexExp to filter out the contents of the body tag.
Re: How to combine multiple .html files together into one .html
It doesn't work. I tried:
Code:
textEdit->insertHtml(test1);
textEdit->insertHtml("<hr>");
textEdit->insertHtml(test2);
The output is:
Code:
v2.6.3
v2.7.0
-----------------
Re: How to combine multiple .html files together into one .html
Try using QTextEdit::append() or control where you insert data using QTextCursor API.