本文整理汇总了C++中QPrinter::setOutputFormat方法的典型用法代码示例。如果您正苦于以下问题:C++ QPrinter::setOutputFormat方法的具体用法?C++ QPrinter::setOutputFormat怎么用?C++ QPrinter::setOutputFormat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPrinter
的用法示例。
在下文中一共展示了QPrinter::setOutputFormat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: exportRect
//-------------------------------------------------------------------------
void MainWindow::exportRect(const QRectF& exportRectangle , const QString& fileName , const QString& fileType )
{
QList<QLanguageItem*> selectedItems = selectedLanguageItems();
unselectAll();
QPainter painter;
if ( fileType == PNG_FILE_FILTER )
{
int result = QResolutionDialog( exportRectangle , EXPORT_MIN_DETAIL , EXPORT_MAX_DETAIL , EXPORT_DEFAULT_DETAIL , EXPORT_DETAIL_TO_SCALE_FACTOR ).exec();
if ( result )
{
//Create a new QImage, with a size corresponding to the Guido Score page
QSizeF size( exportRectangle.width() , exportRectangle.height() );
size.setWidth( result * EXPORT_DETAIL_TO_SCALE_FACTOR * size.width() );
size.setHeight( result * EXPORT_DETAIL_TO_SCALE_FACTOR * size.height() );
QImage image( size.width() , size.height() , QImage::Format_ARGB32);
image.fill( QColor(Qt::white).rgb() );
painter.begin( &image );
//Paint in the QImage
paintSceneRect( exportRectangle , &painter );
painter.end();
image.save( fileName , "PNG" );
}
}
else if ( ( fileType == PDF_FILE_FILTER ) || ( fileType == PS_FILE_FILTER ) )
{
QPrinter printer;
printer.setFullPage(true);
printer.setOutputFileName( fileName );
if ( fileType == PS_FILE_FILTER )
{
printer.setOutputFormat( QPrinter::PostScriptFormat );
}
else if ( fileType == PDF_FILE_FILTER )
{
printer.setOutputFormat( QPrinter::PdfFormat );
}
printer.setPaperSize( QSizeF( exportRectangle.width() , exportRectangle.height() ) , QPrinter::Millimeter );
painter.setWindow( exportRectangle.toRect() );
painter.begin( &printer );
paintSceneRect( exportRectangle , &painter );
painter.end();
}
for ( int i = 0 ; i < selectedItems.size() ; i++ )
selectedItems[i]->setSelected(true);
}
示例2: export_to_pdf_ps
void SvgCanvas::export_to_pdf_ps(int width, int height, QString filename)
{
QPainter plot;
QPrinter p;
p.setFullPage(true);
p.setPageSize(QPrinter::Custom);
if( filename.endsWith(".pdf") )
p.setOutputFormat(QPrinter::PdfFormat);
else
p.setOutputFormat(QPrinter::PostScriptFormat);
p.setOutputFileName(filename);
plot.begin(&p);
svg_plot->renderer()->render(&plot);
plot.end();
}
示例3: 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);
}
示例4: 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();
}
示例5: 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();
}
示例6: 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();
}
示例7: 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();
}
示例8: print
/**
* Methode permettant d'imprimer un document
*/
void ValidDocument::print(){
QWebView webView;
QPrinter printer ;
printer.setPageSize(QPrinter::A4);
printer.setFullPage(true);
QString type=(docType==Document::Facture)?QObject::trUtf8("Facture"):QObject::trUtf8("Devis");
printer.setDocName(type+"_"+QString::number(id) );
printer.setCreator(QObject::trUtf8("QFacturation"));
printer.setOutputFormat(QPrinter::NativeFormat);
webView.setHtml(view);
webView.show();
QPrintDialog printDialog(&printer);
if(printDialog.exec() == QDialog::Accepted) {
qDebug("Ne fonctionne pas sous windows")<<" Hack ....";
#if defined(Q_WS_WIN)
QTextDocument text;
text.setHtml(view);
text.print(&printer);
#endif
#if defined(Q_WS_QWS)
webView.print(&printer);
#endif
#if defined(Q_WS_X11)
webView.print(&printer);
#endif
}
}
示例9: 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);
}
}
}
示例10: print
bool ignsystem::print(const QVariant &config){
QVariantMap conf = jsonParse->jsonParser(config).toVariantMap();
QPrinter print;
QTextDocument *doc = new QTextDocument();
QString type = conf["type"].toString();
QString txt = conf["content"].toString();
QString out = conf["out"].toString();
if(type == "html")
{
doc->setHtml(txt);
}
else
{
doc->setPlainText(txt);
}
if(out == "pdf"){
print.setOutputFormat(QPrinter::PdfFormat);
}
QPrintDialog *dialog = new QPrintDialog(&print);
if (dialog->exec() != QDialog::Accepted)
{
return false;
}
else
{
doc->print(&print);
delete doc;
return true;
}
}
示例11: saveAllSheetsToPDF
void MainWindow::saveAllSheetsToPDF(QString &fileName)
{
QPrinter *printer = new QPrinter(QPrinter::PrinterResolution);
printer->setOutputFormat(QPrinter::PdfFormat);
printer->setOutputFileName(fileName);
printAllSheets(printer);
}
示例12: print
bool ignsystem::print(const QVariant &config) {
QVariantMap configuration = jsonParse->jsonParser(config).toVariantMap();
QPrinter printer;
QTextDocument *document = new QTextDocument();
QPrintDialog *printDialog = new QPrintDialog(&printer);
QString type = configuration[QStringLiteral("type")].toString();
QString content = configuration[QStringLiteral("content")].toString();
QString output = configuration[QStringLiteral("out")].toString();
if (type == QLatin1String("html")) {
document->setHtml(content);
} else {
document->setPlainText(content);
}
if (output == QLatin1String("pdf")) {
printer.setOutputFormat(QPrinter::PdfFormat);
}
if (printDialog->exec() == QDialog::Accepted) {
document->print(&printer);
delete document;
return true;
} else {
return false;
}
}
示例13: setOutputFormat
int Printer::setOutputFormat(lua_State * L) // ( OutputFormat format )
{
QPrinter* lhs = ValueBinding<MyQPrinter>::check( L, 1 );
QPrinter::OutputFormat f=(QPrinter::OutputFormat)Util::toInt( L, 2 );
lhs->setOutputFormat( f );
return 0;
}
示例14: exportToPdf
//-------------------------------------------------------------------------
void QGuidoItemContainer::exportToPdf(const QString& fileName)
{
QPrinter printer;
printer.setFullPage(true);
printer.setOutputFileName( fileName );
printer.setOutputFormat( QPrinter::PdfFormat );
exportToPdf( &printer );
}
示例15: 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() );
}