Hello,

I tried to print 2 textEdit in a row, but i got only one. My code can print both "textEdit_7" and a Customplot but when "commentary==1" i don't get the extra "textEdit_9" that i want in my document. Infact when "commentary==1" i only have textEdit_9 on my sheet, not the previous.
What can i do to fix that ?

Here is my code :

void FenMain::on_pushButton_3_clicked()
{
ui->textEdit_7->setText("");
QTextCursor cursor = ui->textEdit_7->textCursor();
QTextCursor cursoor = ui->textEdit_9->textCursor();

// insert the current plot at the cursor position. QCPDocumentObject::generatePlotFormat creates a
// vectorized snapshot of the passed plot (with the specified width and height) which gets inserted
// into the text document.
cursor.insertText("State of last cycle ");
cursor.insertText(QDateTime::currentDateTime().toS tring("dd/MM/yyyy hh:mm"));
cursor.insertText(QString(QChar::ObjectReplacement Character), QCPDocumentObject::generatePlotFormat(ui->CustomPlot, 700, 300));
cursor.insertText("Comment :");

ui->textEdit_7->setTextCursor(cursor);
ui->textEdit_9->setTextCursor(cursoor);
QString fileName = QFileDialog::getSaveFileName(this, "Save document...", qApp->applicationDirPath(), "*.pdf");

if (!fileName.isEmpty())
{
if (!(fileName.contains(".pdf")) && !(fileName.contains(".PDF")))
{
fileName.append(".pdf");
}
}
QPrinter printer;
printer.setFullPage(true);
printer.setPaperSize(QPrinter::A4);
printer.setOrientation(QPrinter::Portrait);
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setOutputFileName(fileName);
ui->textEdit_7->document()->print(&printer);
if(commentary == 1)
{
ui->textEdit_9->document()->print(&printer);
commentary=0;
}
else {}
QDesktopServices::openUrl(QUrl(fileName));
}

Best regards,