init2null
20th March 2008, 18:15
Hello all,
I'm working on a program that needs to print images of documents, and I'm stumped on how to rotate the contents to print sideways, so as to fill all available space. In my scene, I have an image (which defines the size of the scene) and various primitives. Centering and scaling the document in proportion on the page are my goals, but getting this to work would be a great start. The code I'm trying here only moves the image partway in from the left, cutting off part of it. Any ideas?
bool AreaWindow::showPrintDialog() {
QPrinter printer(QPrinter::HighResolution);
QPrintDialog printDialog(&printer, this);
printDialog.setMinMax(1, 1);
if (printDialog.exec() == QDialog::Accepted) {
QPainter painter(&printer);
if (image.width() > image.height()) {
painter.rotate(90);
painter.translate(0, -image.height());
}
scene->render(&painter);
return true;
}
return false;
}
I'm working on a program that needs to print images of documents, and I'm stumped on how to rotate the contents to print sideways, so as to fill all available space. In my scene, I have an image (which defines the size of the scene) and various primitives. Centering and scaling the document in proportion on the page are my goals, but getting this to work would be a great start. The code I'm trying here only moves the image partway in from the left, cutting off part of it. Any ideas?
bool AreaWindow::showPrintDialog() {
QPrinter printer(QPrinter::HighResolution);
QPrintDialog printDialog(&printer, this);
printDialog.setMinMax(1, 1);
if (printDialog.exec() == QDialog::Accepted) {
QPainter painter(&printer);
if (image.width() > image.height()) {
painter.rotate(90);
painter.translate(0, -image.height());
}
scene->render(&painter);
return true;
}
return false;
}