can't set the pagesize properly to print in a 80mm printer
Unsolved
General and Desktop
-
I tried to set pageSize to 80x297 mm for printing but all the text seems to be written for an a4 size, this all seems like a stupid problem and I am probably doing something wrong but I can not figure out what the problem is.
void MainWindow::on_actionimprimi_triggered() { QPrinter printer; printer.setPageOrientation(QPageLayout::Portrait); printer.setPageSize(QPageSize(QSizeF(80, 297), QPageSize::Millimeter, "teste12")); // Tamanho do papel: 80mm de largura, altura indefinida (rolo) printer.setFullPage(true); qDebug() << printer.pageLayout().pageSize(); // here this function returns the right size (80, 297) QPrintDialog dialog(&printer, this); if(dialog.exec() == QDialog::Rejected) return; QPainter painter; painter.begin(&printer); QFont font = painter.font(); font.setPointSize(8); painter.setFont(font); painter.drawText(Qt::AlignCenter ,Qt::AlignCenter,"teste"); qDebug() << printer.pageLayout().pageSize(); // here the function returns A4 size painter.end(); }
In the second qdebug statement it returns a4 size when I select "print to pdf"
-
@hskoglund when I put setPageSize() after painter.begin(&printer) the Qdebug returns "QPrinter::setPageLayout: Cannot be changed while printer is active" I have tried to put this lines after, before and none of this seems to work
-
Hi,
Which version of Qt are you using ?
On which platform ?