I am using QTextEdit for this. Method insertHtml() helped. But this method works not as I imagine.
My file1.html is
<html>
<body>
<p>
<h2>title1</h2>
<ul>
<li>bla</li>
<li>bla</li>
</ul>
</p>
<br>
</body>
</html>
<html>
<body>
<p>
<h2>title1</h2>
<ul>
<li>bla</li>
<li>bla</li>
</ul>
</p>
<br>
</body>
</html>
To copy to clipboard, switch view to plain text mode
File2.html is
<html>
<body>
<p>
<h2>title2</h2>
<ul>
<li>blabla</li>
<li>blabla</li>
</ul>
</p>
<br>
</body>
</html>
<html>
<body>
<p>
<h2>title2</h2>
<ul>
<li>blabla</li>
<li>blabla</li>
</ul>
</p>
<br>
</body>
</html>
To copy to clipboard, switch view to plain text mode
My code is:
{
if (fileName1.endsWith(".html"))
textEdit->insertHtml(data1);
}
{
if (fileName2.endsWith(".html"))
textEdit->insertHtml(data2);
}
QString fileName1(":/file1.html");
QFile file1(fileName1);
if (file1.open(QIODevice::ReadOnly))
{
QString data1(file1.readAll());
if (fileName1.endsWith(".html"))
textEdit->insertHtml(data1);
}
QString fileName2(":/file2.html");
QFile file2(fileName2);
if (file2.open(QIODevice::ReadOnly))
{
QString data2(file2.readAll());
if (fileName2.endsWith(".html"))
textEdit->insertHtml(data2);
}
To copy to clipboard, switch view to plain text mode
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:
textEdit->insertHtml("<hr>");
textEdit->insertHtml("<hr>");
To copy to clipboard, switch view to plain text mode
The line is beneath the file2's title. crazy!
Anyone can help? Or is there another way to complish this function?
Thanks.
Bookmarks