This question has already been answered:

I have too large text and therefore gives error C1091: compiler limit: string exceeds 65535 bytes in length. I decided to split this line into two parts and put in qtextedit? That is, I have:

QTextEdit* TextEdit = new QTextEdit("...<P ALIGN=JUSTIFY STYLE=\"margin-bottom: 0.14in\"><BR><BR>" "</P>" "<P ALIGN=JUSTIFY STYLE=\"margin-bottom: 0.14in\"><BR><BR>" "</P>..."); QTextEdit* TextEditOne = new QTextEdit("...<P>Какой то текст</P>..."; 

How do I take two pieces of text from two QTextEdit and write to one file? I do this:

 QString fileName = QFileDialog::getSaveFileName(this, tr("Файл ODT"),"",tr("Файлы ODT (*.odt)")); if (fileName.isEmpty()) return; QTextDocumentWriter writer(fileName); QTextDocument *m_document = new QTextDocument(); bool success; m_document=TextEdit->document(); m_document+=TextEditOne->document(); success = writer.write(m_document); if (success) { QMessageBox::information(this, "Отлично!", "Экспорт прошел успешно"); } else { QMessageBox::critical(this, "Ошибка", "При сохранении файла произошла ошибка"); } 

But I constantly get a message that pops up: An error occurred while saving the file

Reported as a duplicate by Harry c ++ Aug 6 '18 at 13:28 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

    1 answer 1

    Write all your text to the file, add the file to the resources and read and write where you need from the resources.

    • An example is possible? I need to automatically add data from the database to this file - Ivan Triumphov