Important: Please read the Qt Code of Conduct -

QPrinter print in Qt with QPainter

  • Hello Forum,

    my next Project is printing. I have a code than i print four words on the left/top site.

    @ QString printText = "Test Text zum Drucken";

    QPrinter printer;
    QPrintDialog *dialog = new QPrintDialog(&printer);
    dialog->setWindowTitle("Print Document");
    if(dialog->exec() != QDialog::Accepted)
        QMessageBox::critical(this,"Error","Fehler beim öffnen des Druckers");
    QPainter painter;
    painter.drawText(100,100,500,500,Qt::AlignLeft|Qt::AlignTop, printText);

    When the text is longer i can´t print correct on a A4 site. What is wrong with this code.
    Must need a another code or other parameters?

    Alex from Germany

Log in to reply