C++ (Qt) QPrinter printer; QTextDocument *doc = new QTextDocument( this ); doc->setHtml( document ); QPrintDialog *dlg = new QPrintDialog(&printer, this); if (dlg->exec() != QDialog::Accepted) return; doc->print( &printer );
C++ (Qt) QPrinter printer; QPrintPreviewDialog *ppd = new QPrintPreviewDialog( &printer, this ); connect( ppd, SIGNAL(paintRequested(QPrinter *) ), this, SLOT(printDocument(QPrinter*))); ppd->exec();}void Statement::printDocument(QPrinter* printer){ QTextDocument *doc = new QTextDocument( this ); doc->setHtml( document ); QPainter painter; painter.begin(printer); doc->drawContents(&painter); painter.end();}