sipahi
6th February 2013, 17:48
I create QTextTable and populate it with data.
Then I print out table via using QTextDocument.
I can print out table successfully. But in some pages cells are divided.
For example If my cell is three lines, first line of table is in bottom of 5. page, second and third lines of table are in top of 6. page.
How do I get rid of this problem?
I create QTextTable:
TextDocument *document=new QTextDocument(this);
QTextCursor cursor(document);
cursor.movePosition(QTextCursor::Start);
QTextTableCellFormat cellFormat;
cellFormat.setLeftPadding(7);
cellFormat.setRightPadding(7);
cellFormat.setTopPadding(2);
QBrush blackBrush(Qt::SolidPattern);
QTextTableFormat tableFormat;
tableFormat.setAlignment(Qt::AlignLeft);
tableFormat.setBorderBrush(blackBrush);
tableFormat.setBorder(0.5);
tableFormat.setCellSpacing(0);
tableFormat.setBorderStyle(QTextFrameFormat::Borde rStyle_Solid);
tableFormat.setWidth(QTextLength(QTextLength::Perc entageLength, 100));
QTextTable *table = cursor.insertTable(100,10,tableFormat);
QTextTableCell cell=table->cellAt(1,0);
cell.setFormat(cellFormat);
cell.firstCursorPosition().insertText("this is long sentence");
....
And I print out:
QPrinter printer;
printer.setOrientation(QPrinter::Landscape);
printer.setPageMargins(10,10,10,50,QPrinter::Milli meter);
QPrintDialog *dlg = new QPrintDialog(&printer, this);
if (dlg->exec() != QDialog::Accepted)
return;
document->print(&printer);
sorry for my English
Then I print out table via using QTextDocument.
I can print out table successfully. But in some pages cells are divided.
For example If my cell is three lines, first line of table is in bottom of 5. page, second and third lines of table are in top of 6. page.
How do I get rid of this problem?
I create QTextTable:
TextDocument *document=new QTextDocument(this);
QTextCursor cursor(document);
cursor.movePosition(QTextCursor::Start);
QTextTableCellFormat cellFormat;
cellFormat.setLeftPadding(7);
cellFormat.setRightPadding(7);
cellFormat.setTopPadding(2);
QBrush blackBrush(Qt::SolidPattern);
QTextTableFormat tableFormat;
tableFormat.setAlignment(Qt::AlignLeft);
tableFormat.setBorderBrush(blackBrush);
tableFormat.setBorder(0.5);
tableFormat.setCellSpacing(0);
tableFormat.setBorderStyle(QTextFrameFormat::Borde rStyle_Solid);
tableFormat.setWidth(QTextLength(QTextLength::Perc entageLength, 100));
QTextTable *table = cursor.insertTable(100,10,tableFormat);
QTextTableCell cell=table->cellAt(1,0);
cell.setFormat(cellFormat);
cell.firstCursorPosition().insertText("this is long sentence");
....
And I print out:
QPrinter printer;
printer.setOrientation(QPrinter::Landscape);
printer.setPageMargins(10,10,10,50,QPrinter::Milli meter);
QPrintDialog *dlg = new QPrintDialog(&printer, this);
if (dlg->exec() != QDialog::Accepted)
return;
document->print(&printer);
sorry for my English