PDA

View Full Version : printing problem



igor_x
7th November 2006, 08:16
Hi!
Tell me please is there any another way to print rich text? -
In the richtext example there is :

void MainWindow::printFile()
{
QTextEdit *editor = static_cast<QTextEdit*>(letters->currentWidget());
QTextDocument *document = editor->document();
QPrinter printer;
printer.setOrientation(QPrinter::Landscape);
printer.setFullPage(false);
printer.setPageSize ( QPrinter::A4 );
QPrintDialog *dialog = new QPrintDialog(&printer, this);
dialog->setWindowTitle(tr("Print Document"));
if (dialog->exec() != QDialog::Accepted)
return;
reporter->setWordWrapMode ( QTextOption::WrapAnywhere );
document->print(&printer);
}
but QTextEdit lost some options - such as editor->setWordWrapMode ( QTextOption::WrapAnywhere ); during printing.

What to do ?

Thanks!
--
Igor

igor_x
7th November 2006, 11:30
I have found folloving: it happend only in tables, but in simple text all settings work properly.... Maybe someting wrong in my code?

igor_x
8th November 2006, 10:35
and here is the example of wierd wordwrapping - see attachment pls

wysota
8th November 2006, 10:50
The problem is that you are trying to influence the text editor, whereas you are printing the document which is displayed by the editor. Word wrapping is only relevant for rendering the document to the text edit, it won't influence the way the document is printed on the printer. I think you should operate on the QPrinter object directly or on the QTextDocument object which represents the document itself.