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:
spacings.jpg

Resulting HTML code (within <body> tag):
Qt Code:
  1. <body style=" font-family:'Times New Roman'; font-size:12pt; font-weight:400; font-style:normal;">
  2. <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Single spacing:</p>
  3. <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq</p>
  4. <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>
  5. <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>
  6. <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq</p>
  7. <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>
  8. <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Double spacing:</p>
  9. <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq</p></body>
To copy to clipboard, switch view to plain text mode 

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:

Qt Code:
  1. QTextBlockFormat fmt = cursorToHandle.blockFormat();
  2. fmt.setLineHeight(c_spacing, QTextBlockFormat::ProportionalHeight); // c_spacing is 100 for single, 150 for 1.5 and 200 for double
  3. cursorToHandle.setBlockFormat(fmt);
To copy to clipboard, switch view to plain text mode 

Here is code that saves document:

Qt Code:
  1. QString strDocHtml = m_pDoc->toHtml();
  2. QSharedPointer<QFile> pFile(new QFile(c_strFilePath));
  3. if (!pFile->open(QIODevice::WriteOnly))
  4. {
  5. return false;
  6. }
  7. return pFile->write(strDocHtml.toStdString().c_str());
To copy to clipboard, switch view to plain text mode 

Here is code for loading:

Qt Code:
  1. QFile file(c_strFilePath);
  2. if (!file.open(QFile::ReadOnly))
  3. {
  4. return false;
  5. }
  6.  
  7. QByteArray data = file.readAll();
  8. QTextCodec* pCodec = Qt::codecForHtml(data);
  9. QString strRawHtml = pCodec->toUnicode(data);
  10.  
  11. m_pDoc->setHtml(strRawHtml);
  12. }
To copy to clipboard, switch view to plain text mode 

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.