当前位置: 首页>>代码示例>>C++>>正文


C++ QPrinter::setPageSize方法代码示例

本文整理汇总了C++中QPrinter::setPageSize方法的典型用法代码示例。如果您正苦于以下问题:C++ QPrinter::setPageSize方法的具体用法?C++ QPrinter::setPageSize怎么用?C++ QPrinter::setPageSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QPrinter的用法示例。


在下文中一共展示了QPrinter::setPageSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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();

}
开发者ID:py1668,项目名称:xpracman-qt2-final,代码行数:31,代码来源:qmvformtool.cpp

示例2: setPageSize

int Printer::setPageSize(lua_State * L) // (  PageSize newPageSize  )
{
	QPrinter* lhs = ValueBinding<MyQPrinter>::check( L, 1 );
	QPrinter::PageSize f=(QPrinter::PageSize)Util::toInt( L, 2 );
	lhs->setPageSize( f );
	return 0;
}
开发者ID:Wushaowei001,项目名称:NAF,代码行数:7,代码来源:QtlPrinter.cpp

示例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();
}
开发者ID:BackupTheBerlios,项目名称:qtiplot-svn,代码行数:60,代码来源:multilayer.cpp

示例4: 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);
    }
}
开发者ID:SorinS,项目名称:fop-miniscribus,代码行数:30,代码来源:PageFormatGroup.cpp

示例5: 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
    }

}
开发者ID:Ducatel,项目名称:QFacturation,代码行数:35,代码来源:validdocument.cpp

示例6: image

void OpenInfraPlatform::UserInterface::Alignment2DScene::exportToFile(QWidget* parent)
{
	QString filter;
	QString fn = QFileDialog::getSaveFileName(parent, tr("Save Vertical Alignment as..."), QString(), tr("PNG File (*.png);; JPG File (*.jpg);; PDF File (*.pdf);; SVG File (*.svg)"), &filter);
	if(fn.isEmpty())
		return;

	if(filter == "PNG File (*.png)" || filter == "JPG File (*.jpg)")
	{
		QImage image(sceneRect().size().toSize(), QImage::Format::Format_ARGB32);
		image.fill(Qt::darkGray);

		QPainter painter(&image);
		painter.setRenderHints(QPainter::Antialiasing);
		render(&painter);
		image.save(fn);
	}
	else
	{
		QPrinter printer;
		QSvgGenerator svgGen;

		QPaintDevice* device;
		if(filter == "PDF File (*.pdf)")
		{
			printer.setResolution(QPrinter::HighResolution);
			printer.setPageSize( QPrinter::A4 );
			printer.setOrientation( QPrinter::Landscape );
			printer.setOutputFormat( QPrinter::PdfFormat );
			printer.setOutputFileName(fn);

			device = &printer;
		}
		else if(filter == "SVG File (*.svg)")
		{
			QRectF rect = sceneRect(); 

			svgGen.setFileName(fn);
			svgGen.setSize(QSize(rect.width(),rect.height()));
			svgGen.setViewBox(QRect(0,0,rect.width(),rect.height()));
			svgGen.setTitle("Vertical Alignment");			
			
			device = &svgGen;
		}
		else
		{
			return;
		}

		QPainter painter(device);

		configureColors(A2D_DrawState::A2D_Print);
		render(&painter);
		configureColors(A2D_DrawState::A2D_Draw);
	}
}
开发者ID:bigdoods,项目名称:OpenInfraPlatform,代码行数:56,代码来源:Alignment2DScene.cpp

示例7: print

void Document::print()
{
	QPrinter printer;
	printer.setPageSize(QPrinter::Letter);
	printer.setPageMargins(0.5, 0.5, 0.5, 0.5, QPrinter::Inch);
	QPrintDialog dialog(&printer, this);
	if (dialog.exec() == QDialog::Accepted) {
		m_text->print(&printer);
	}
}
开发者ID:quickhand,项目名称:Prosit,代码行数:10,代码来源:document.cpp

示例8: getPageMetrics

/** Gets the metrics for the selected page size & orientation */
QSize MReportEngine::getPageMetrics( int size, int orientation ) {

  QSize ps;

  // Set the page size

  if (( QPrinter::PageSize ) size == QPrinter::Custom ) {
    ps.setWidth( customWidthMM / 25.4 * 78. );
    ps.setHeight( customHeightMM / 25.4 * 78. );
    return ps;
  }

#if defined(Q_OS_WIN32)
  if ( !printToPos ) {
    PSPrinter *printer = new PSPrinter( PSPrinter::HighResolution );
    printer->setFullPage( true );
    printer->setPageSize(( PSPrinter::PageSize ) size );
    printer->setOrientation(( PSPrinter::Orientation ) orientation );
    QPaintDeviceMetrics pdm( printer );
    ps.setWidth( pdm.widthMM() / 25.4 * 78. );
    ps.setHeight( pdm.heightMM() / 25.4 * 78. );
    delete printer;
  } else {
    FLPosPrinter * printer = new FLPosPrinter();
    QPaintDeviceMetrics pdm( printer );
    ps.setWidth( pdm.widthMM() / 25.4 * 78. );
    ps.setHeight( pdm.heightMM() / 25.4 * 78. );
    delete printer;
  }

#else
  if ( !printToPos ) {
    QPrinter * printer = new QPrinter( QPrinter::HighResolution );
    printer->setFullPage( true );
    printer->setPageSize(( QPrinter::PageSize ) size );
    printer->setOrientation(( QPrinter::Orientation ) orientation );
    QPaintDeviceMetrics pdm( printer );
    ps.setWidth( pdm.widthMM() / 25.4 * 78. );
    ps.setHeight( pdm.heightMM() / 25.4 * 78. );
    delete printer;
  } else {
    FLPosPrinter * printer = new FLPosPrinter();
    QPaintDeviceMetrics pdm( printer );
    ps.setWidth( pdm.widthMM() / 25.4 * 78. );
    ps.setHeight( pdm.heightMM() / 25.4 * 78. );
    delete printer;
  }

#endif

  return ps;
}
开发者ID:AliYousuf,项目名称:abanq-port,代码行数:53,代码来源:mreportengine.cpp

示例9: print

void Document::print()
{
	QPrinter printer;
	printer.setPageSize(QPrinter::Letter);
	printer.setPageMargins(0.5, 0.5, 0.5, 0.5, QPrinter::Inch);
	QPrintDialog dialog(&printer, this);
	if (dialog.exec() == QDialog::Accepted) {
		bool enabled = m_highlighter->enabled();
		m_highlighter->setEnabled(false);
		m_text->print(&printer);
		if (enabled) {
			m_highlighter->setEnabled(true);
		}
	}
}
开发者ID:rcjavier,项目名称:focuswriter,代码行数:15,代码来源:document.cpp

示例10: 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();
}
开发者ID:OpticaMonografia,项目名称:QtOctave,代码行数:15,代码来源:svgcanvas.cpp

示例11: on_pushButton_clicked

//dugme za stampu uputa
void Uput::on_pushButton_clicked()
{


    QPrinter *printer = new QPrinter;


    QPrintDialog *printDialog = new QPrintDialog(printer, this);
    if (printDialog->exec() == QDialog::Accepted)
    {
        ui->pushButton->setVisible(false);
        ui->lineEdit->setReadOnly(true);
        ui->textEdit->setReadOnly(true);
        printer->setPageSize(printer->Letter);
        Uput::setVisible(false);
        Uput::setGeometry(0,0,769,400);
        this->render(printer);
        Uput::close();
    }
}
开发者ID:perakojot,项目名称:Infirmaria-qt,代码行数:21,代码来源:uput.cpp

示例12: generatePDF

bool ReportGenerator::generatePDF(QString templateFilename, QString outputAbsolutePath)
{
    QFile templateFile(":/reports/Reports/"+templateFilename);

    if(!templateFile.open(QIODevice::ReadOnly | QIODevice::Text))
    {
        return false;
    }

    QTextStream templateStream(&templateFile);

    QTextDocument document;
    document.setHtml(templateStream.readAll());

    QList<QString> keys = this->vars.keys();
    QList<QString>::iterator keysIt;

    for(keysIt = keys.begin(); keysIt != keys.end(); ++keysIt)
    {
        QTextCursor cursor(&document);
        while(!cursor.isNull())
        {
            cursor = document.find("%"+(*keysIt)+"%", cursor);
            cursor.insertHtml(this->vars[(*keysIt)]);
        }
    }

    QPrinter* printer = new QPrinter(QPrinter::HighResolution);
    printer->setPageSize(QPrinter::A4);
    printer->setOutputFormat(QPrinter::PdfFormat);

    printer->setOutputFileName(outputAbsolutePath);

    WebViewPrinter* wv = new WebViewPrinter();
    wv->printer = printer;

    wv->setHtml(document.toHtml());

    return true;

}
开发者ID:AnomalyDetection2012,项目名称:AnomalyDetection2012PWR,代码行数:41,代码来源:ReportGenerator.cpp

示例13: on_pushButton_print_clicked

/**
   Impression du livre des recettes
  */
void DialogInvoiceList::on_pushButton_print_clicked() {
	//Si on est pas connecte on sort
	if((!m_data->isConnected()) || (ui->tableWidget_Invoices->rowCount()<=0) )return;

	QPrinter printer;
	printer.setPageSize(QPrinter::A4);
	QString name = tr("LIVRERECETTES-")+ m_date.toString(tr("yyyyMM")) ;
	printer.setOutputFileName( name + ".pdf");
	printer.setDocName( name );
	printer.setCreator("mcercle");

	DialogPrintChoice *m_DialogPrintChoice = new DialogPrintChoice(&printer);
	m_DialogPrintChoice->setModal(true);
	m_DialogPrintChoice->exec();

	if(m_DialogPrintChoice->result() == QDialog::Accepted) {
		QWidget fenetre;
		QPrintPreviewDialog m_PreviewDialog(&printer,  &fenetre, Qt::Widget | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint);
		connect(&m_PreviewDialog, SIGNAL(paintRequested(QPrinter *)), this, SLOT(on_paintPrinter(QPrinter *)));
		m_PreviewDialog.setWindowState(Qt::WindowMaximized);
		m_PreviewDialog.exec();
	}
开发者ID:cfdev,项目名称:mcercle,代码行数:25,代码来源:dialoginvoicelist.cpp

示例14:

int LuaPrinter2::setPageSize(lua_State *L)
{
	QPrinter* obj = ValueInstaller<LuaPrinter2>::check( L, 1 );
	obj->setPageSize( (QPrinter::PageSize)(int)luaL_checknumber( L, 2 ) );
	/*
		A0 (841 x 1189 mm) 
		A1 (594 x 841 mm) 
		A2 (420 x 594 mm) 
		A3 (297 x 420 mm) 
		A4 (210x297 mm, 8.26x11.7 inches) 
		A5 (148 x 210 mm) 
		A6 (105 x 148 mm) 
		A7 (74 x 105 mm) 
		A8 (52 x 74 mm) 
		A9 (37 x 52 mm) 
		B0 (1030 x 1456 mm) 
		B1 (728 x 1030 mm) 
		B10 (32 x 45 mm) 
		B2 (515 x 728 mm) 
		B3 (364 x 515 mm) 
		B4 (257 x 364 mm) 
		B5 (182x257 mm, 7.17x10.13 inches) 
		B6 (128 x 182 mm) 
		B7 (91 x 128 mm) 
		B8 (64 x 91 mm) 
		B9 (45 x 64 mm) 
		C5E (163 x 229 mm) 
		Comm10E (105 x 241 mm, US Common #10 Envelope) 
		DLE (110 x 220 mm) 
		Executive (7.5x10 inches, 191x254 mm) 
		Folio (210 x 330 mm) 
		Ledger (432 x 279 mm) 
		Legal (8.5x14 inches, 216x356 mm) 
		Letter (8.5x11 inches, 216x279 mm) 
		Tabloid (279 x 432 mm) 
	*/
	return 0;
}
开发者ID:Wushaowei001,项目名称:NAF,代码行数:38,代码来源:LuaMyWidget2.cpp

示例15:

void GL_widget_2::export_to_vector(QString file_name) {
	QPrinter printer;
	printer.setOutputFileName(file_name);
	printer.setResolution(72);
	printer.setPageSize(QPrinter::A0);
	//	printer.setOrientation(QPrinter::Landscape); //ps would be not correct
	printer.setFullPage(true);
	printer.setColorMode(QPrinter::Color);


	QPainter painter;
	set_renderer_type(GL_widget_2::QT_PAINTER);
	set_painter(&painter);
	painter.begin(&printer);
	paint_to_painter();
	painter.end();
	set_painter(0);
	set_renderer_type(GL_widget_2::OPEN_GL);

	if (printer.printerState() < 2) // idle or active
		std::cout << "Image written to " << file_name.toStdString() << std::endl;
	else
		std::cout << "Could not write image to " << file_name.toStdString() << std::endl;
}
开发者ID:UhtredBosch,项目名称:mesecina,代码行数:24,代码来源:GL_widget_2.cpp


注:本文中的QPrinter::setPageSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。