Qt 6.11 is out! See what's new in the release
blog
How change FontSize at print
-
Hi!
How change FontSize at print?
It's not work:void MainWindow::PrintDocument(QString &TextForPrint) //PrintDocument { QPrinter MyPrinter; QPrintDialog *PrinterDialog = new QPrintDialog(&MyPrinter); PrinterDialog->setWindowTitle("Print"); QFont FontForPrint; FontForPrint.setPointSize(22); //PrinterDialog->setFont(FontForPrint); if (PrinterDialog->exec()) { QPainter MyPainter; MyPainter.begin(&MyPrinter); MyPainter.drawText(100, 100, 400, 400, Qt::AlignLeft|Qt::AlignTop, TextForPrint); MyPainter.setFont(FontForPrint); MyPainter.end(); } } -
Hi!
How change FontSize at print?
It's not work:void MainWindow::PrintDocument(QString &TextForPrint) //PrintDocument { QPrinter MyPrinter; QPrintDialog *PrinterDialog = new QPrintDialog(&MyPrinter); PrinterDialog->setWindowTitle("Print"); QFont FontForPrint; FontForPrint.setPointSize(22); //PrinterDialog->setFont(FontForPrint); if (PrinterDialog->exec()) { QPainter MyPainter; MyPainter.begin(&MyPrinter); MyPainter.drawText(100, 100, 400, 400, Qt::AlignLeft|Qt::AlignTop, TextForPrint); MyPainter.setFont(FontForPrint); MyPainter.end(); } }@Mikeeeeee said in How change FontSize at print:
It's not work:
Does it change the
font? then u have to take font fromQPrinterand then try to modify font.
Something like thisQFont font = MyPrinter.font() ; -
Hi
You set font After you draw the text.