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


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

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


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

示例1: logicalDpiX

int QPrinterProto::logicalDpiX() const
{
  QPrinter *item = qscriptvalue_cast<QPrinter*>(thisObject());
  if (item)
    return item->logicalDpiX();
  return 0;
}
开发者ID:AlFoX,项目名称:qt-client,代码行数:7,代码来源:qprinterproto.cpp

示例2: printf

void printerInvoice::printf(const QString &html)
{
	QPrinter p;
	QTextDocument doc;
	QFont font = doc.defaultFont();
	font.setBold(true);
	font.setPointSize(font.pointSize());
	doc.setDefaultFont(font);
	QSizeF s = QSizeF(p.logicalDpiX() * 7.5, p.logicalDpiY() * 7.5);
	doc.setPageSize(s);
	p.setOutputFormat(QPrinter::NativeFormat);
	doc.setHtml(html);
	doc.print(&p);
}
开发者ID:bighome,项目名称:Jewelry_System,代码行数:14,代码来源:printerinvoice.cpp

示例3: exportVector

void Matrix::exportVector(const QString& fileName, int res, bool color, bool keepAspect, QPrinter::PageSize pageSize)
{
    if (d_view_type != ImageView)
        return;

	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);

    int cols = numCols();
    int rows = numRows();
    QRect rect = QRect(0, 0, cols, rows);
    if (pageSize == QPrinter::Custom)
        printer.setPageSize(Graph::minPageSize(printer, rect));
    else
        printer.setPageSize(pageSize);

    double aspect = (double)cols/(double)rows;
	if (aspect < 1)
		printer.setOrientation(QPrinter::Portrait);
	else
		printer.setOrientation(QPrinter::Landscape);

    if (keepAspect){// export should preserve aspect ratio
        double page_aspect = double(printer.width())/double(printer.height());
        if (page_aspect > aspect){
            int margin = (int) ((0.1/2.54)*printer.logicalDpiY()); // 1 mm margins
            int height = printer.height() - 2*margin;
            int width = int(height*aspect);
            int x = (printer.width()- width)/2;
            rect = QRect(x, margin, width, height);
        } else if (aspect >= page_aspect){
            int margin = (int) ((0.1/2.54)*printer.logicalDpiX()); // 1 mm margins
            int width = printer.width() - 2*margin;
            int height = int(width/aspect);
            int y = (printer.height()- height)/2;
            rect = QRect(margin, y, width, height);
        }
	} else {
	    int x_margin = (int) ((0.1/2.54)*printer.logicalDpiX()); // 1 mm margins
        int y_margin = (int) ((0.1/2.54)*printer.logicalDpiY()); // 1 mm margins
        int width = printer.width() - 2*x_margin;
        int height = printer.height() - 2*y_margin;
        rect = QRect(x_margin, y_margin, width, height);
	}

    QPainter paint(&printer);
    paint.drawImage(rect, d_matrix_model->renderImage());
    paint.end();
}
开发者ID:BackupTheBerlios,项目名称:qtiplot-svn,代码行数:66,代码来源:Matrix.cpp


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