Thanks. I solved my problem
pixmap
=QPixmap::grabWindow(ui
->widget
->winId
());
printer.
setOrientation(QPrinter::Landscape);
printer.
setOutputFormat(QPrinter::PdfFormat);
printer.
setOutputFileName(QApplication::applicationDirPath()+QDir::separator()+"file");
QRect rect
=painter.
viewport();
QSize size
=pixmap.
size();
size.scale(rect.size(), Qt::KeepAspectRatio);
painter.setViewport(rect.x(), rect.y(), size.width(), size.height());
painter.setWindow(pixmap.rect());
painter.drawPixmap(0,0,100,100,pixmap);
QPixmap pixmap;
pixmap=QPixmap::grabWindow(ui->widget->winId());
QPrinter printer;
printer.setOrientation(QPrinter::Landscape);
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setOutputFileName(QApplication::applicationDirPath()+QDir::separator()+"file");
QPainter painter(&printer);
QRect rect=painter.viewport();
QSize size=pixmap.size();
size.scale(rect.size(), Qt::KeepAspectRatio);
painter.setViewport(rect.x(), rect.y(), size.width(), size.height());
painter.setWindow(pixmap.rect());
painter.drawPixmap(0,0,100,100,pixmap);
To copy to clipboard, switch view to plain text mode
Bookmarks