qt - QtTextEdit: text content not rendered to QPainter -


i have difficulties rendering context of qtextedit painter (which prints pdf). other widgets correctly printed, text of qtextwidget not.

the widgets fine in gui:

qtextedit in widget

but text of qtextwidget not printed pdf:

enter image description here

the code quite simple. perhaps need add additional flags? text rendered same looks in gui, seperate rendering of text (using textfield->document()->drawcontents(&painter), not best solution)

qtextedit* textfield= ... // textedit correctly visible  qprinter printer(qprinter::highresolution); ... qpainter painter( &printer ); textfield->render(&painter, qpoint(), qregion(), qwidget::drawchildren); 

there nothing wrong code snippet. tried:

void mainwindow::on_pushbutton_clicked() { qprinter printer(qprinter::highresolution); printer.setoutputformat(qprinter::pdfformat); printer.setoutputfilename("output.pdf"); qpainter painter( &printer ); ui->textedit->render(&painter, qpoint(), qregion(), qwidget::drawchildren); } 

and work's. i'm using qt 5.5.1. enter image description here

you try (as alternative) textedit->print(printer); or painter->drawtext(printer.pagerect(), ui->textedit->toplaintext());


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -