Details
-
Bug
-
Resolution: Out of scope
-
P2: Important
-
4.4.0
-
None
Description
QTextDocument::print: Page break after a table messes up the printed output.
Test case main.cpp to reproduce
=======================================
// Testcase for QTextDocument::print
#include <QtGui>
static void addTable(QTextCursor& cursor)
{
const int columns = 4;
const int rows = 1;
QTextTableFormat tableFormat;
//tableFormat.setHeaderRowCount( 1 );
QTextTable* textTable = cursor.insertTable( rows + 1,columns,tableFormat );
QTextCharFormat tableHeaderFormat;
tableHeaderFormat.setBackground( QColor( "#DADADA" ) );
QStringList headers;
headers << "Product" << "Reference" << "Price" << "Price with shipping";
for( int column = 0; column < columns; column++ )
{ QTextTableCell cell = textTable->cellAt( 0, column ); Q_ASSERT( cell.isValid() ); cell.setFormat( tableHeaderFormat ); QTextCursor cellCursor = cell.firstCursorPosition(); cellCursor.insertText( headers[column] ); } int row = 0;
for( int column = 0; column < columns; column++ )
}
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QTextDocument textDocument;
QTextCursor cursor(&textDocument);
cursor.insertText("This is the first page");
addTable(cursor);
QTextBlockFormat blockFormat;
blockFormat.setPageBreakPolicy(QTextFormat::PageBreak_AlwaysBefore);
cursor.insertBlock(blockFormat);
cursor.insertText("This is the second page");
QTextEdit edit;
edit.setDocument(&textDocument);
edit.show();
QPrinter printer;
printer.setOutputFileName("test.pdf");
printer.setFullPage(true);
textDocument.print(&printer);
return app.exec();
}