Questions and Problems Regarding QPrint
-
Hello all
I have a few questions regarding QPrint
-
If some part of the text is bold how can i do it so it will be bold. I tried wrapping the text between <B></B> and [B][/B]
-
I want to keep things tidy like a grid and put texts inside those. How can i achieve a neat structure. I tried adding spaces manually. However not every character have the same width, especially space, and keeping them tidy is hard. Example:
Name : Value <enough space here> Name2 : Value2
Name1 : Value1 <enough space here> Name3 : Value3
... -
When i use the code below. Although left and top margins are not passed over, right margin is passed over. I just can't understand why. I don't want to use '\n' manually.
QPrinter printer(QPrinter::HighResolution);
printer.setPageSize(QPrinter::A4);
printer.setOrientation(QPrinter::Portrait);
printer.setPageMargins (15, 15, 15, 15, QPrinter::Point);
printer.setFullPage(false);
printer.setOutputFileName("çıktı.pdf");
printer.setOutputFormat(QPrinter::PdfFormat);
QPainter painter(&printer);
painter.setFont(QFont("Tahoma", 8));painter.drawText(printer.pageRect(), result);
Thanks in advance.
-
-
@Corpse0327
Hi
you would set the font bold.1: QFont f("Tahoma", 18); f.setBold(true); painter.setFont(f);
2:
Well you could use tabs or position the text yourself. like QString t1("Peter:400"); QString t2("Thomas:400"); int aw=painter.fontMetrics().averageCharWidth(); painter.drawText(60, 100, t1); painter.drawText(60+(aw*20), 100, t2); // next col 20 chars out
Basically you "print" as would would draw something on screen.
Some of the controls, like TextDocument can print them self also. -
QPrinter printer(QPrinter::HighResolution); printer.setPageSize(QPrinter::A4); printer.setOrientation(QPrinter::Portrait); printer.setPageMargins (15, 15, 15, 15, QPrinter::Point); printer.setFullPage(false); printer.setOutputFileName("çıktı.pdf"); printer.setOutputFormat(QPrinter::PdfFormat); QPainter painter(&printer); QFont font = painter.font(); font.setBold(true); painter.setFont(font); painter.drawText(printer.pageRect(), result);