Grantlee looks interesting. I have to look a bit closer.
I was just playing around with the HTML/parser approach. Results are frustrating. In a table I do:
"<td><div id='xyz'>some text</div></td>"
"<td><div id='xyz'>some text</div></td>"
To copy to clipboard, switch view to plain text mode
I use setHtml() and then toHtml() to read it back. I get
<td bgcolor="#ffffff">
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a name="xyz"></a>some text</p></td>
<td bgcolor="#ffffff">
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a name="xyz"></a>some text</p></td>
To copy to clipboard, switch view to plain text mode
QTextEdit makes my <div> to <a>
An it does not enclose the text at all. Looks like this approach fails.
Added after 1 14 minutes:
Hm, this is more complicated than expected. This complete QText.... API is pretty irritating compared to the rest of Qt (which is from my of view very straight forward). Maybe someone can give me a slap to push me into the right direction. Here is what I try to do:
textEdit->clear();
cursor.setBlockFormat(blockHeading1);
cursor.setCharFormat(textHeading1);
cursor.insertText(data.title);
diaryFrame = cursor.insertFrame(frameStandard);
{
QTextCursor cursor
= diaryFrame
->firstCursorPosition
();
cursor.setBlockFormat(blockStandard);
cursor.setCharFormat(textStandard);
cursor.insertText(tr("Add your own text here..."));
}
cursor.insertBlock(blockHeading2, textHeading2);
cursor.insertText(tr("Waypoints"));
textEdit->clear();
QTextCursor cursor = textEdit->textCursor();
cursor.setBlockFormat(blockHeading1);
cursor.setCharFormat(textHeading1);
cursor.insertText(data.title);
diaryFrame = cursor.insertFrame(frameStandard);
{
QTextCursor cursor = diaryFrame->firstCursorPosition();
cursor.setBlockFormat(blockStandard);
cursor.setCharFormat(textStandard);
cursor.insertText(tr("Add your own text here..."));
}
cursor.insertBlock(blockHeading2, textHeading2);
cursor.insertText(tr("Waypoints"));
To copy to clipboard, switch view to plain text mode
This will generate some text. In the frame "diaryFrame" the user can edit what ever is desired. The editor allows font selection, fontweight, color and all the usual stuff. In the end I want to read back the text within that frame as HTML. But how? Do I miss the obvious?
Oliver
Bookmarks