本文整理汇总了C++中QPrinter::setOutputFileName方法的典型用法代码示例。如果您正苦于以下问题:C++ QPrinter::setOutputFileName方法的具体用法?C++ QPrinter::setOutputFileName怎么用?C++ QPrinter::setOutputFileName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPrinter
的用法示例。
在下文中一共展示了QPrinter::setOutputFileName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QString
bool KDReports::Report::exportToFile( const QString& fileName, QWidget* parent )
{
d->ensureLayouted();
QPrinter printer;
d->setupPrinter( &printer );
printer.setOutputFileName( fileName );
const bool ret = d->doPrint( &printer, parent );
printer.setOutputFileName( QString() );
return ret;
}
示例2: setupPrinter
bool KDReports::Report::exportToFile( const QString& fileName, QWidget* parent )
{
d->ensureLayouted();
QPrinter printer;
printer.setOutputFileName( fileName ); // must be done before setupPrinter, since it affects DPI
setupPrinter( &printer );
const bool ret = d->doPrint( &printer, parent );
printer.setOutputFileName( QString() );
return ret;
}
示例3: exportToEPS
void MultiLayer::exportToEPS(const QString& fname, int res, QPrinter::Orientation o,
QPrinter::PageSize pageSize, QPrinter::ColorMode col)
{
QPrinter printer;
printer.setResolution(res);
printer.setPageSize(pageSize);
printer.setColorMode(col);
printer.setOrientation(o);
printer.setFullPage(TRUE);
printer.setOutputToFile (TRUE);
printer.setOutputFileName(fname);
QPainter paint(&printer);
QPaintDeviceMetrics pdmTo(&printer);
int dpiy = pdmTo.logicalDpiY();
int margin = (int) ( (0.5/2.54)*dpiy ); // 5 mm margins
QSize size = canvas->size();
double scaleFactorX=(double)(pdmTo.width() - 2*margin)/(double)size.width();
double scaleFactorY=(double)(pdmTo.height() - 2*margin)/(double)size.height();
for (int i=0;i<(int)graphsList->count();i++)
{
Graph *gr=(Graph *)graphsList->at(i);
Plot *myPlot= (Plot *)gr->plotWidget();
PrintFilter filter(myPlot);
filter.setOptions(QwtPlotPrintFilter::PrintAll | QwtPlotPrintFilter::PrintTitle
| QwtPlotPrintFilter::PrintCanvasBackground);
QPoint pos=gr->pos();
pos=QPoint(int(margin + pos.x()*scaleFactorX),int(margin + pos.y()*scaleFactorY));
int width=int(myPlot->frameGeometry().width()*scaleFactorX);
int height=int(myPlot->frameGeometry().height()*scaleFactorY);
QRect rect = QRect(pos,QSize(width,height));
if (myPlot->paletteBackgroundColor() != QColor(white))
paint.fillRect(rect, myPlot->paletteBackgroundColor());
int lw = myPlot->lineWidth();
if ( lw > 0)
{
myPlot->printFrame(&paint, rect);
rect.moveBy ( lw, lw);
rect.setWidth(rect.width() - 2*lw);
rect.setHeight(rect.height() - 2*lw);
}
myPlot->print(&paint, rect, filter);
}
if (hasOverlapingLayers())
updateTransparency();
}
示例4: main
int main(int argc, char** argv)
{
Genome* g(new Genome());
std::string fileName;
if (argc > 1) {
fileName = argv[1];
}
else {
fileName = "out.sam";
}
g->read(fileName);
QApplication app(argc, argv);
LinearPlot lp();
auto seed = g->getReadAt(1, 1);
assume(seed != nullptr, "Error, no read found!");
lp.setSceneRect(0, 0, 1200, 300);
lp.fromRead(seed, g);
QGraphicsView view(&lp);
view.setWindowTitle("Chipboard demo v0.0.1");
view.show();
QPrinter printer;
printer.setPaperSize(QSize(view.width(), view.height()), QPrinter::Point);
printer.setFullPage(true);
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setOutputFileName("plot.pdf");
QPainter pdfPainter;
pdfPainter.begin(&printer);
view.render(&pdfPainter);
return app.exec();
}
示例5: exportVector
void MultiLayer::exportVector(const QString &fileName, int res, bool color,
bool keepAspect, QPrinter::PageSize pageSize,
QPrinter::Orientation orientation) {
Q_UNUSED(res);
if (fileName.isEmpty()) {
QMessageBox::critical(this, tr("Error"),
tr("Please provide a valid file name!"));
return;
}
QPrinter printer;
printer.setDocName(this->name());
printer.setCreator("AlphaPlot");
printer.setFullPage(true);
printer.setOutputFileName(fileName);
if (fileName.contains(".eps"))
printer.setOutputFormat(QPrinter::PostScriptFormat);
if (color)
printer.setColorMode(QPrinter::Color);
else
printer.setColorMode(QPrinter::GrayScale);
if (pageSize == QPrinter::Custom)
printer.setPaperSize(canvas->size(), QPrinter::Point);
else {
printer.setOrientation(orientation);
printer.setPaperSize(pageSize);
}
exportPainter(printer, keepAspect);
}
示例6: slotExportAsPdf
void KexiReportView::slotExportAsPdf()
{
QScopedPointer<KoReportRendererBase> renderer(m_factory.createInstance("print"));
if (renderer) {
KoReportRendererContext cxt;
cxt.destinationUrl = getExportUrl(QLatin1String("application/pdf"),
xi18n("Export Report as PDF"),
"kfiledialog:///LastVisitedPDFExportPath/",
"pdf");
if (!cxt.destinationUrl.isValid()) {
return;
}
QPrinter printer;
QPainter painter;
printer.setOutputFileName(cxt.destinationUrl.path());
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setColorMode(QPrinter::Color);
painter.begin(&printer);
cxt.printer = &printer;
cxt.painter = &painter;
if (!renderer->render(cxt, m_reportDocument)) {
KMessageBox::error(this,
xi18n("Exporting the report as PDF to %1 failed.", cxt.destinationUrl.toDisplayString()),
xi18n("Export Failed"));
} else {
openExportedDocument(cxt.destinationUrl);
}
}
}
示例7: CollectWidgets
void ribi::braw::QtPrintRatingDialog::Print(const std::string& filename)
{
QPrinter printer;
printer.setOrientation(QPrinter::Portrait);
printer.setPaperSize(QPrinter::A4);
printer.setFullPage(false);
printer.setOutputFileName(filename.c_str());
//Draw the image to painter to printer (?must be done before printing)
QPainter painter;
painter.begin(&printer);
{
//Collect widgets to print
const std::vector<QWidget *> widgets = CollectWidgets();
int y = 0;
for (QWidget * const widget: widgets)
{
const int h = widget->height();
if (y+h > painter.window().height())
{
printer.newPage();
y = 0;
}
widget->render(&painter,QPoint(0,y));
y+=h;
}
}
painter.end();
}
示例8: saveAllSheetsToPDF
void MainWindow::saveAllSheetsToPDF(QString &fileName)
{
QPrinter *printer = new QPrinter(QPrinter::PrinterResolution);
printer->setOutputFormat(QPrinter::PdfFormat);
printer->setOutputFileName(fileName);
printAllSheets(printer);
}
示例9: exportToPDF
void MainWindowController:: exportToPDF()
{
QString fileName = QFileDialog::getSaveFileName(nullptr, tr("Choose PDF location"), "", tr("PDF File(*.pdf)"));
QPrinter prn;
prn.setOutputFileName(QString(fileName));
//QPrintDialog(&prn, mainWindow).exec();
prn.setOrientation(QPrinter::Landscape);
QPainter painter;
painter.begin(&prn);
double x = this->view->getUi()->gameLayout_2->width();
painter.translate(prn.paperRect().x() + 20,
prn.paperRect().y()+20);
this->view->getUi()->gameLayout_2->render(&painter);
painter.translate(prn.paperRect().x() + x,
prn.paperRect().y());
QFont font;
font.setPixelSize(12);
painter.setFont(font);
for (int i = 0 ; i < this->view->getUi()->definitionWidget->count() ; i++)
{
painter.drawText(QPoint(10,10),this->view->getUi()->definitionWidget->item(i)->text() );
if(i %40 == 0&&i>1)
{
painter.translate(QPoint(prn.paperRect().x()+200,
-600));
}
else
{
painter.translate(QPoint(prn.paperRect().x(),
prn.paperRect().y()+15));
}
}
}
示例10: doPrintParameterStatistic
void MainWindow::doPrintParameterStatistic()
{
if ( gv_PS.count() > 0 )
{
QTextDocument textDocu;
QPrinter printer;
QPrintDialog printDialog( &printer, this );
printer.setOrientation( QPrinter::Landscape );
if ( printDialog.exec() == QDialog::Accepted )
{
QFileInfo fi( gsl_FilenameList.at( 0 ) );
QFont textFont = QFont( gf_HeaderTextFont.family(), 10, 0, false );
printer.setOutputFileName( tr( "" ) );
textDocu.setHtml( createParameterStatisticOutputText( fi.fileName(), gv_PS ) );
textDocu.setDefaultFont( textFont );
textDocu.print( &printer );
}
update();
}
setStatusBar( tr( "Done" ), 2 );
}
示例11: saveAsDocument
void PageScreen::saveAsDocument(const QString &format)
{
const QString &suffix = QLatin1Char('.') + format.toLower();
QString pathWithoutSuffix = ui->location->text();
if (pathWithoutSuffix.endsWith(suffix, Qt::CaseInsensitive)) {
pathWithoutSuffix = pathWithoutSuffix.mid(0, pathWithoutSuffix.length() - suffix.length());
}
QPrinter printer;
printer.setCreator(QupZilla::tr("QupZilla %1 (%2)").arg(QupZilla::VERSION, QupZilla::WWWADDRESS));
printer.setOutputFileName(pathWithoutSuffix + suffix);
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setPaperSize(m_pageImages.first().size(), QPrinter::DevicePixel);
printer.setPageMargins(0, 0, 0, 0, QPrinter::DevicePixel);
printer.setFullPage(true);
QPainter painter;
painter.begin(&printer);
for (int i = 0; i < m_pageImages.size(); ++i) {
const QImage &image = m_pageImages.at(i);
painter.drawImage(0, 0, image);
if (i != m_pageImages.size() - 1) {
printer.newPage();
}
}
painter.end();
}
示例12: on_button_clicked
void Dialog::on_button_clicked()
{
const QString filename = "CppQPrinterExample2.pdf";
//Set up a QPrinter
QPrinter printer;
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setOrientation(QPrinter::Portrait);
printer.setPaperSize(QPrinter::A4);
printer.setFullPage(false);
printer.setOutputFileName(filename);
//Grab the window
const QImage image = QPixmap::grabWindow(this->winId()).toImage();
//Draw the image to painter to printer
QPainter painter;
painter.begin(&printer);
painter.drawImage(0,0,image);
painter.end();
//Start the printer
boost::shared_ptr<QPrintDialog> dialog(new QPrintDialog(&printer));
dialog->exec();
}
示例13: exportVector
void Matrix::exportVector(const QString& fileName, int res, bool color)
{
if ( fileName.isEmpty() ){
QMessageBox::critical(this, tr("QtiPlot - Error"), tr("Please provide a valid file name!"));
return;
}
QPrinter printer;
printer.setCreator("QtiPlot");
printer.setFullPage(true);
if (res)
printer.setResolution(res);
printer.setOutputFileName(fileName);
if (fileName.contains(".eps"))
printer.setOutputFormat(QPrinter::PostScriptFormat);
if (color)
printer.setColorMode(QPrinter::Color);
else
printer.setColorMode(QPrinter::GrayScale);
printer.setOrientation(QPrinter::Portrait);
int cols = numCols();
int rows = numRows();
QRect rect = QRect(0, 0, cols, rows);
printer.setPaperSize(QSizeF(cols, rows), QPrinter::DevicePixel);
QPainter paint(&printer);
paint.drawImage(rect, d_matrix_model->renderImage());
paint.end();
}
示例14: beginPrintAsPDF
void QgsComposition::beginPrintAsPDF( QPrinter& printer, const QString& file )
{
printer.setOutputFormat( QPrinter::PdfFormat );
printer.setOutputFileName( file );
printer.setPaperSize( QSizeF( paperWidth(), paperHeight() ), QPrinter::Millimeter );
QgsPaintEngineHack::fixEngineFlags( printer.paintEngine() );
}
示例15: exportToPdf
//-------------------------------------------------------------------------
void QGuidoItemContainer::exportToPdf(const QString& fileName)
{
QPrinter printer;
printer.setFullPage(true);
printer.setOutputFileName( fileName );
printer.setOutputFormat( QPrinter::PdfFormat );
exportToPdf( &printer );
}