本文整理汇总了C++中QPrinter::setColorMode方法的典型用法代码示例。如果您正苦于以下问题:C++ QPrinter::setColorMode方法的具体用法?C++ QPrinter::setColorMode怎么用?C++ QPrinter::setColorMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPrinter
的用法示例。
在下文中一共展示了QPrinter::setColorMode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
示例2: 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);
}
示例3: print
void Printer::print()
{
// we can only print if "PRINT" mode is selected
if (printMode != Printer::PRINT) {
return;
}
QPrinter *printerPtr;
printerPtr = static_cast<QPrinter*>(paintDevice);
TemplateLayout t(printOptions, templateOptions);
connect(&t, SIGNAL(progressUpdated(int)), this, SLOT(templateProgessUpdated(int)));
dpi = printerPtr->resolution();
//rendering resolution = selected paper size in inchs * printer dpi
pageSize.setHeight(qCeil(printerPtr->pageRect(QPrinter::Inch).height() * dpi));
pageSize.setWidth(qCeil(printerPtr->pageRect(QPrinter::Inch).width() * dpi));
webView->page()->setViewportSize(pageSize);
webView->page()->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
// export border width with at least 1 pixel
// templateOptions->borderwidth = std::max(1, pageSize.width() / 1000);
if (printOptions->type == print_options::DIVELIST) {
webView->setHtml(t.generate());
} else if (printOptions->type == print_options::STATISTICS ) {
webView->setHtml(t.generateStatistics());
}
if (printOptions->color_selected && printerPtr->colorMode()) {
printerPtr->setColorMode(QPrinter::Color);
} else {
printerPtr->setColorMode(QPrinter::GrayScale);
}
// apply user settings
int divesPerPage;
// get number of dives per page from data-numberofdives attribute in the body of the selected template
bool ok;
divesPerPage = webView->page()->mainFrame()->findFirstElement("body").attribute("data-numberofdives").toInt(&ok);
if (!ok) {
divesPerPage = 1; // print each dive in a single page if the attribute is missing or malformed
//TODO: show warning
}
int Pages;
if (divesPerPage == 0) {
flowRender();
} else {
Pages = qCeil(getTotalWork(printOptions) / (float)divesPerPage);
render(Pages);
}
}
示例4: 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);
}
}
}
示例5: setColorMode
int Printer::setColorMode(lua_State * L) // ( ColorMode newColorMode )
{
QPrinter* lhs = ValueBinding<MyQPrinter>::check( L, 1 );
QPrinter::ColorMode f=(QPrinter::ColorMode)Util::toInt( L, 2 );
lhs->setColorMode( f );
return 0;
}
示例6: 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();
}
示例7: 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() );
}
示例8: slotPRINTER
void MyTextBrowser::slotPRINTER()
{
QPrinter printer;
printer.setColorMode(QPrinter::Color);
QPrintDialog dialog(&printer);
if (dialog.exec() == QDialog::Accepted)
{
PRINT(&printer);
}
}
示例9: print
void MultiLayer::print()
{
QPrinter printer;
printer.setResolution(84);
printer.setOrientation(QPrinter::Landscape);
printer.setColorMode (QPrinter::Color);
printer.setFullPage(TRUE);
if (printer.setup())
{
QPainter paint(&printer);
printAllLayers(&paint);
paint.end();
}
}
示例10: saveAsPdf
void MainWindow::saveAsPdf(const QString& fileName) const
{
if (fileName != "")
{
QPrinter pdfPrinter;
pdfPrinter.setOutputFormat(QPrinter::PdfFormat);
pdfPrinter.setOutputFileName(fileName);
pdfPrinter.setColorMode(QPrinter::Color);
Printer::applySettings(&pdfPrinter, printer);
QPainter painter(&pdfPrinter);
view->paint(painter, pdfPrinter);
}
}
示例11: on_printFileButton_clicked
void CompareDialog::on_printFileButton_clicked()
{
QPrinter printer;
QString filename = QFileDialog::getSaveFileName(this, tr("Select PDF output file"), QString(), "Pdf File(*.pdf)");
printer.setPageMargins(10.0, 10.0, 10.0, 10.0, printer.Millimeter);
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setOrientation(QPrinter::Landscape);
printer.setColorMode(QPrinter::Color);
if (!filename.isEmpty()) {
if (QFileInfo(filename).suffix().isEmpty())
filename.append(".pdf");
printer.setOutputFileName(filename);
ui->textEdit->print(&printer);
}
}
示例12: sizeMM
void
MSPeaksWnd::handlePrintCurrentView( const QString& pdfname )
{
// A4 := 210mm x 297mm (8.27 x 11.69 inch)
QSizeF sizeMM( 260, 160 ); // 260x160mm
int resolution = 300;
const double mmToInch = 1.0 / 25.4;
const QSizeF size = sizeMM * mmToInch * resolution;
double margin_left = 0.2 /* inch */ * resolution;
//double margin_right = ( 8.27 - 0.2 ) * resolution;
//double margin_center = (margin_right - margin_left) / 2 + margin_left;
QPrinter printer;
printer.setColorMode( QPrinter::Color );
printer.setPaperSize( QPrinter::A4 );
printer.setFullPage( false );
printer.setOrientation( QPrinter::Landscape );
printer.setDocName( "QtPlatz MS Peaks" );
printer.setOutputFileName( pdfname );
printer.setResolution( resolution );
//--------------------
QPainter painter( &printer );
int n = 0;
for ( auto& plot: plots_ ) {
QRectF boundingRect;
QRectF drawRect( margin_left, 0.0, printer.width() / 2.0, printer.height() );
if ( n++ & 01 ) {
drawRect.moveLeft( printer.width() / 2.0 );
painter.drawText( drawRect, Qt::TextWordWrap, "Relationship between time and flight length", &boundingRect );
} else {
painter.drawText( drawRect, Qt::TextWordWrap, "Relationship between time and m/z", &boundingRect );
}
QwtPlotRenderer renderer;
renderer.setDiscardFlag( QwtPlotRenderer::DiscardCanvasBackground, true );
renderer.setDiscardFlag( QwtPlotRenderer::DiscardCanvasFrame, true );
renderer.setDiscardFlag( QwtPlotRenderer::DiscardBackground, true );
drawRect.setTop( boundingRect.bottom() );
drawRect.setHeight( size.height() );
drawRect.setWidth( size.width() / 2 );
renderer.render( plot.get(), &painter, drawRect ); // render plot
}
}
示例13: print
void Matrix::print(const QString& fileName)
{
QPrinter printer;
printer.setColorMode (QPrinter::GrayScale);
if (!fileName.isEmpty()){
printer.setCreator("QtiPlot");
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setOutputFileName(fileName);
} else {
QPrintDialog printDialog(&printer, applicationWindow());
if (printDialog.exec() != QDialog::Accepted)
return;
}
printer.setFullPage( true );
print(&printer);
}
示例14: print
void QgsComposition::print( QPrinter &printer )
{
//set resolution based on composer setting
printer.setFullPage( true );
printer.setColorMode( QPrinter::Color );
//set user-defined resolution
printer.setResolution( printResolution() );
QPainter p( &printer );
//QgsComposition starts page numbering at 0
int fromPage = ( printer.fromPage() < 1 ) ? 0 : printer.fromPage() - 1 ;
int toPage = ( printer.toPage() < 1 ) ? numPages() - 1 : printer.toPage() - 1;
if ( mPrintAsRaster )
{
for ( int i = fromPage; i <= toPage; ++i )
{
if ( i > fromPage )
{
printer.newPage();
}
QImage image = printPageAsRaster( i );
if ( !image.isNull() )
{
QRectF targetArea( 0, 0, image.width(), image.height() );
p.drawImage( targetArea, image, targetArea );
}
}
}
if ( !mPrintAsRaster )
{
for ( int i = fromPage; i <= toPage; ++i )
{
if ( i > fromPage )
{
printer.newPage();
}
renderPage( &p, i );
}
}
}
示例15: print
void MultiLayer::print() {
QPrinter printer;
printer.setColorMode(QPrinter::Color);
printer.setFullPage(true);
QRect canvasRect = canvas->rect();
double aspect = double(canvasRect.width()) / double(canvasRect.height());
if (aspect < 1)
printer.setOrientation(QPrinter::Portrait);
else
printer.setOrientation(QPrinter::Landscape);
QPrintDialog printDialog(&printer);
if (printDialog.exec() == QDialog::Accepted) {
QPainter paint(&printer);
printAllLayers(&paint);
paint.end();
}
}