Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QPainter::draw() ingnores \n
QT-static-prgm last edited by
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?
We give it an area (rect) instead of x,y only