本文整理汇总了C++中QPrinter::setFullPage方法的典型用法代码示例。如果您正苦于以下问题:C++ QPrinter::setFullPage方法的具体用法?C++ QPrinter::setFullPage怎么用?C++ QPrinter::setFullPage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPrinter
的用法示例。
在下文中一共展示了QPrinter::setFullPage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
示例2: 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();
}
示例3: 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();
}
示例4: filePrint
void Help::filePrint()
{
QPrinter printer;
printer.setFullPage(TRUE);
if ( printer.setup() ) {
QPainter p( &printer );
QPaintDeviceMetrics metrics(p.device());
int dpix = metrics.logicalDpiX();
int dpiy = metrics.logicalDpiY();
const int margin = 72; // pt
QRect body(margin*dpix/72, margin*dpiy/72,
metrics.width()-margin*dpix/72*2,
metrics.height()-margin*dpiy/72*2 );
QFont font("times", 10);
QSimpleRichText richText( browser->text(), font, browser->context(), browser->styleSheet(),
browser->mimeSourceFactory(), body.height() );
richText.setWidth( &p, body.width() );
QRect view( body );
int page = 1;
for (;;) {
richText.draw( &p, body.left(), body.top(), view, colorGroup() );
view.moveBy( 0, body.height() );
p.translate( 0 , -body.height() );
p.setFont( font );
p.drawText( view.right() - p.fontMetrics().width( QString::number(page) ),
view.bottom() + p.fontMetrics().ascent() + 5, QString::number(page) );
if ( view.top() >= richText.height() )
break;
printer.newPage();
page++;
}
}
}
示例5: M_PagesizeMake
QRectF M_PagesizeMake( QPrinter::PageSize psize , bool landscape)
{
QPrinter *print = new QPrinter(QPrinter::HighResolution);
print->setFullPage(true);
print->setPageSize(psize);
if (landscape)
{
print->setOrientation(QPrinter::Landscape);
}
else
{
print->setOrientation(QPrinter::Portrait);
}
const QRectF pa = print->pageRect(QPrinter::Point);
const qreal faktor = qMax(pa.width(),pa.height()) / qMin(pa.width(),pa.height());
const qreal smaller = qMin(pa.width(),pa.height());
const qreal biger = smaller * faktor;
delete print;
if ( landscape )
{
return QRectF(0,0,biger,smaller);
}
else
{
return QRectF(0,0,smaller,biger);
}
}
示例6: 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();
}
示例7: 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
}
}
示例8: print
void Qt_help_window::print()
{
#ifndef QT_NO_PRINTER
QPrinter printer;
printer.setFullPage(TRUE);
if ( printer.setup( this ) ) {
QPainter p( &printer );
QPaintDeviceMetrics metrics(p.device());
int dpix = metrics.logicalDpiX();
int dpiy = metrics.logicalDpiY();
const int margin = 72; // pt
QRect body(margin*dpix/72, margin*dpiy/72,
metrics.width()-margin*dpix/72*2,
metrics.height()-margin*dpiy/72*2 );
QSimpleRichText richText( browser->text(), QFont(), browser->context(), browser->styleSheet(),
browser->mimeSourceFactory(), body.height() );
richText.setWidth( &p, body.width() );
QRect view( body );
int page = 1;
do {
richText.draw( &p, body.left(), body.top(), view, colorGroup() );
view.moveBy( 0, body.height() );
p.translate( 0 , -body.height() );
p.drawText( view.right() - p.fontMetrics().width( QString::number(page) ),
view.bottom() + p.fontMetrics().ascent() + 5, QString::number(page) );
if ( view.top() >= richText.height() )
break;
printer.newPage();
page++;
} while (TRUE);
}
#endif
}
示例9: 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();
}
示例10: 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();
}
示例11: 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);
}
示例12: buildBackgroundPixmap
// --------------------------------------------------------------------------------
void QmvFormTool::buildBackgroundPixmap( )
{
// Determine page size using a QPinter object
QPrinter* prt;
QSize ps;
// Set the page size
prt = new QPrinter();
prt->setFullPage(true);
prt->setPageSize( (QPrinter::PageSize) fh->form_pagesize.toInt() );
prt->setOrientation( (QPrinter::Orientation) fh->form_orientation.toInt() );
// Get the page metrics
QPaintDeviceMetrics pdm(prt);
ps.setWidth(pdm.width());
ps.setHeight(pdm.height());
delete prt;
background.resize( ps );
pagesize = ps;
background.fill( getTransparentColor() );
// clear the canvas event index
canvas_details.setAutoDelete(FALSE);
canvas_details.clear();
}
示例13: print
void HelpBrowser::print()
{
QPrinter printer;
printer.setFullPage(true);
QPrintDialog dialog(&printer, this);
if (dialog.exec())
textBrowser->print(&printer);
}
示例14: exportToPdf
//-------------------------------------------------------------------------
void QGuidoItemContainer::exportToPdf(const QString& fileName)
{
QPrinter printer;
printer.setFullPage(true);
printer.setOutputFileName( fileName );
printer.setOutputFormat( QPrinter::PdfFormat );
exportToPdf( &printer );
}
示例15: beginPrint
void QgsComposition::beginPrint( QPrinter &printer )
{
//set resolution based on composer setting
printer.setFullPage( true );
printer.setColorMode( QPrinter::Color );
//set user-defined resolution
printer.setResolution( printResolution() );
}