Solved QPainter::draw() ingnores \n
-
Hi,
i have a QString with a longer text that contains \n for new lines. The QLabel displays everything correctly. Now i want to save this text as pdf file. I tried Printing the QLabel, but that's not so good because of the resolution. So i thought the better way is to print the text directly instead of display it on a label and print that label.
QPdfWriter pdfwriter("qtwritten.pdf"); pdfwriter.setPageSize(QPageSize(QPageSize::A4)); QPainter painter(&pdfwriter); painter.setFont(*m_font); painter.drawText(0, 0, "Hello\nworld!");
The Result is
Any solution ideas? Or maybe alternatives to write the text to a pdf file?
-
Hi
Trypainter->drawText(this->rect(), Qt::AlignCenter,"Hello\nworld!");
We give it an area (rect) instead of x,y only