1 Attachment(s)
Saving QTextDocument line spacing for inner blocks to HTML file for further usage
Greetings everyone. I'm writing WYSIWYG editor with Qt-4.8 Scribe framework. One of requirements is setting different line spacings for different text blocks. http://www.qtcentre.org/threads/4999...-QTextDocument thread gave me a solution: usage of QTextBlockFormat::setLineHeight(). It works fine but when I save a document with QTextDocumentWriter line spacing is not saved. See picture and code below.
Image:
Attachment 12199
Resulting HTML code (within <body> tag):
Code:
<body style=" font-family:'Times New Roman'; font-size:12pt; font-weight:400; font-style:normal;">
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Single spacing:</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq</p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">One and a half spacing:</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq</p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Double spacing:</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq</p></body>
As you can see, there is no properties like "line-height" within <p style"=..."> tags as well as in http://doc.qt.io/qt-4.8/richtext-html-subset.html (Supported HTML subset). Here is code that sets line spacing:
Code:
fmt.
setLineHeight(c_spacing,
QTextBlockFormat::ProportionalHeight);
// c_spacing is 100 for single, 150 for 1.5 and 200 for double cursorToHandle.setBlockFormat(fmt);
Here is code that saves document:
Code:
QString strDocHtml
= m_pDoc
->toHtml
();
QSharedPointer<QFile> pFile
(new QFile(c_strFilePath
));
{
return false;
}
return pFile->write(strDocHtml.toStdString().c_str());
Here is code for loading:
Code:
QFile file(c_strFilePath
);
if (!file.
open(QFile::ReadOnly)) {
return false;
}
QString strRawHtml
= pCodec
->toUnicode
(data
);
m_pDoc->setHtml(strRawHtml);
}
So the question is: is there any way to save line spacings to *.html file and read it again?
If any additional information is necessary I'll be glad to provide it.
Thanks in advance.
Re: Saving QTextDocument line spacing for inner blocks to HTML file for further usage
Well, seems like it is bug of sorts, because there is no mentions about line-edit block property in documentation. Reported here about this issue.
Re: Saving QTextDocument line spacing for inner blocks to HTML file for further usage
Is there any ability to mark this thread as solved?