Hi folks,
I observe an issue with the rendering of html block elements (with Qt 4.5.3 & 4.6.1 / WinXP):

1. The "Title" 1&2 formats differ only by the appended '<br>' tag, and without it the center alignment is not working. What is wrong here ? How can this be fixed without this extra tag ? (insertBlock() won't help)
2. But this hack does not work for in frame html any more. As you can see in the code for H2 "Frame #1/2 header". Here the '<br>' tag positioned in front makes the hack ?!?
So what do I the wrong way? How is the correct way to declare a frame-wide html block without some hooks ?
// _doc is a QTextDocument*;
c.insertHtml("<div align=\"center\"><h1>Title.</h1></div><br>");
c.insertBlock();
c.insertHtml("<div align=\"center\"><h1>Title 2.</h1></div>");
providerFrame.setBorder( 1.0);
providerFrame.setWidth(200.0);
c.insertHtml("<h2>Frame #1 header.</h2><br>"
"<p>content 1</p>"
"<p>content 2</p>");
c= root->lastCursorPosition();
c.insertBlock();
c.insertHtml("<br><h2>Frame #2 header.</h2>"
"<p>content 1</p>"
"<p>content 2</p>");
c= root->lastCursorPosition();
c.insertHtml("<p>end</p>");
// _doc is a QTextDocument*;
QTextFrame* root= _doc->rootFrame();
QTextCursor c= root->firstCursorPosition();
c.insertHtml("<div align=\"center\"><h1>Title.</h1></div><br>");
c.insertBlock();
c.insertHtml("<div align=\"center\"><h1>Title 2.</h1></div>");
QTextFrameFormat providerFrame;
providerFrame.setBorder( 1.0);
providerFrame.setWidth(200.0);
QTextFrame* f1= c.insertFrame(providerFrame);
c.insertHtml("<h2>Frame #1 header.</h2><br>"
"<p>content 1</p>"
"<p>content 2</p>");
c= root->lastCursorPosition();
c.insertBlock();
QTextFrame* f2= c.insertFrame(providerFrame);
c.insertHtml("<br><h2>Frame #2 header.</h2>"
"<p>content 1</p>"
"<p>content 2</p>");
c= root->lastCursorPosition();
c.insertHtml("<p>end</p>");
To copy to clipboard, switch view to plain text mode
H2 css:
h2 { font-size: 120%; font-weight: bold; background: lightgray; }
h2 { font-size: 120%; font-weight: bold; background: lightgray; }
To copy to clipboard, switch view to plain text mode
>This< seems to be a related post, but unfortunately not solved 
Regards,
lexar
Bookmarks