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


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

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


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

示例1: paperSize

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

示例2: paperSize

AdvancedPdf::PaperSize AdvancedPdf::paperSize(QPrinter::PaperSize paperSize)
{
    QPrinter pr;
    pr.setOutputFormat(QPrinter::PdfFormat);
    pr.setPaperSize(paperSize);
    QSizeF s = pr.paperSize(QPrinter::Point);
    PaperSize p = { qRound(s.width()), qRound(s.height()) };
    return p;
}
开发者ID:02JanDal,项目名称:mapper,代码行数:9,代码来源:printengine_advanced_pdf.cpp

示例3: setGridSize

void ObjectsScene::setGridSize(unsigned size)
{
	if(size >= 20 || grid.style()==Qt::NoBrush)
	{
		QImage grid_img;
		float width, height, x, y;
		int img_w, img_h;
		QSizeF aux_size;
		QPrinter printer;
		QPainter painter;
		QPen pen;

    configurePrinter(&printer);
    aux_size=printer.paperSize(QPrinter::Point);
		aux_size-=page_margins.size();

		//Calculates where the extreme width and height where delimiter lines will be drawn
		width=aux_size.width()/static_cast<float>(size) * size;
		height=aux_size.height()/static_cast<float>(size) * size;

		//Calculates the grid pixmpa size
		img_w=ceil(width/size)*size;
		img_h=ceil(height/size)*size;

		grid_size=size;
		grid_img=QImage(img_w, img_h, QImage::Format_ARGB32);
		grid_img.fill(Qt::white);
		painter.begin(&grid_img);

		if(show_grid)
		{
			pen.setColor(QColor(225, 225, 225));
			painter.setPen(pen);

			//Draws the grid
			for(x=0; x < width; x+=size)
				for(y=0; y < height; y+=size)
					painter.drawRect(QRectF(QPointF(x,y),QPointF(x + size,y + size)));
		}

		//Creates the page delimiter lines
		if(show_page_delim)
		{
			pen.setColor(QColor(75,115,195));
			pen.setStyle(Qt::DashLine);
			pen.setWidthF(1.0f);
			painter.setPen(pen);
			painter.drawLine(width-1, 0,width-1,img_h-1);
			painter.drawLine(0, height-1,img_w-1,height-1);
		}

		painter.end();
		grid.setTextureImage(grid_img);
	}
}
开发者ID:Halfnhav,项目名称:pgmodeler,代码行数:55,代码来源:objectsscene.cpp

示例4: print

bool ChequePrinter::print()
{
    // 0. Amount to readable string
    QString amount;
    QStringList vals = Utils::doubleToHumanReadableString(d->_amount);
    if (vals.count() == 0) {
        LOG_ERROR_FOR("ChecquePrinter", "Wrong amount to string values");
    } else {
        amount = vals.at(0) + " " + QLocale().currencySymbol(QLocale::CurrencyDisplayName) + "s";
        if (vals.count() == 2)
            amount += QString(" %1 %2").arg(tkTr(Trans::Constants::AND)).arg(vals.at(1));
    }

    // Method 1. use pdkcompleter
//    Internal::PdfTkWrapper *pdftk = Internal::PdfTkWrapper::instance();
//    if (!pdftk->initialize())
//        return false;
//    pdftk->beginFdfEncoding();
//    pdftk->addFdfValue("date", QLocale().toString(d->_date, QLocale::ShortFormat));
//    pdftk->addFdfValue("lieu", d->_place);
//    pdftk->addFdfValue("ordre", d->_order);

//    pdftk->addFdfValue("montant1", lines.at(0));
//    if (lines.count() >= 2)
//        pdftk->addFdfValue("montant2", lines.at(1));

//    // Amount to translated number
//    QSystemLocale::CurrencyToStringArgument arg;
//    arg.value = d->_amount;
//    QVariant var;
//    var.setValue<QSystemLocale::CurrencyToStringArgument>(arg);
//    pdftk->addFdfValue("num", QString::number(d->_amount, 'f', 2)); //QSystemLocale().query(QSystemLocale::CurrencyToString, var).toString());

//    QString filename = "/Users/eric/Desktop/cheque.pdf";
//    pdftk->endFdfEncoding(filename);
//    pdftk->fillPdfWithFdf(filename, pdftk->getFdfContent(), "/Users/eric/Desktop/test_cheque.pdf", "ISO-8859-1");

//    return true;

    // Method 2. use QPainter/QPrinter
    // try to use the default printer
    QPrintDialog dlg;
    if (dlg.exec()==QDialog::Rejected)
        return false;
    QPrinter *printer = dlg.printer();
//    printer->setPaperSource(QPrinter::PaperSource);
    printer->setFullPage(true);
    printer->setPaperSize(QPrinter::A4);
    printer->setResolution(150);
    printer->setOrientation(QPrinter::Landscape);
    d->_axisHelper.setPageSize(printer->paperRect(), printer->paperSize(QPrinter::Millimeter));

    QPainter painter;
    if (!painter.begin(printer)) { // failed to open file
        qWarning("failed to open file, is it writable?");
        return false;
    }

    painter.save();
    QFont font;
    font.setPointSize(10);
    painter.setFont(font);

    painter.translate(d->_axisHelper.pointToPixels(120, 61));
    // 25,17 pour certains
    // 45,13 pour d'autres
    QRectF amountLines(d->_axisHelper.pointToPixels(45,13), d->_axisHelper.sizeToPixels(90, 10));
    // QRect amountLine2(d->_axisHelper.pointToPixels(10,23), d->size(110, 5));
    QRectF orderLine(d->_axisHelper.pointToPixels(10,28), d->_axisHelper.sizeToPixels(110, 5));

    QRectF numberLine(d->_axisHelper.pointToPixels(133,28), d->_axisHelper.sizeToPixels(41, 10));
    QRectF placeLine(d->_axisHelper.pointToPixels(133,38), d->_axisHelper.sizeToPixels(40, 4));
    QRectF dateLine(d->_axisHelper.pointToPixels(133,42), d->_axisHelper.sizeToPixels(40, 4));

    if (DrawChequeRects) {
        painter.drawRect(amountLines);
        painter.drawRect(orderLine);
        painter.drawRect(numberLine);
        painter.drawRect(placeLine);
        painter.drawRect(dateLine);
    }

    if (amount.count() > 50)
        amount = Utils::lineWrapString(amount, 50);
    amount = QString("****%1****").arg(amount.toUpper());

    QFontMetrics metrics(font);
    while (metrics.width(amount) > amountLines.width() || font.pointSize() == 6) {
        font.setPointSizeF(font.pointSizeF() - .1);
        metrics = QFontMetrics(font);
    }
    painter.setFont(font);
    painter.drawText(amountLines, Qt::AlignLeft, amount);
    font.setPointSize(10);
    painter.setFont(font);

//    QStringList lines = amount.split("\n", QString::SkipEmptyParts);
//    painter.drawText(amountLine1, Qt::AlignLeft | Qt::AlignVCenter, lines.at(0));
//    if (lines.count() >= 2)
//        painter.drawText(amountLine2, Qt::AlignLeft | Qt::AlignVCenter, lines.at(1));
//.........这里部分代码省略.........
开发者ID:NyFanomezana,项目名称:freemedforms,代码行数:101,代码来源:chequeprinter.cpp

示例5: CHECK_VAR

int MUH_DEFTERI_KEBIR_BATCH::CHECK_VAR ( QObject * object )
{
    SQL_QUERY   sql_query ( DB );

    if ( object EQ m_ui->checkbox_hesap_araligi ) {

        if ( m_ui->checkbox_hesap_araligi->isChecked() EQ false ) {

            sql_query.PREPARE_SELECT("muh_hesaplar" , "tam_hesap_kodu,hesap_ismi" , "parent_id = :parent_id");
            sql_query.SET_VALUE(":parent_id" , 0);

            if ( sql_query.SELECT("tam_hesap_kodu ASC" , 0 , 1) > 0 ) {
                sql_query.NEXT();
                m_ui->search_edit_bas_hesabi->SET_TEXT ( sql_query.VALUE(0).toString() );
                m_ui->lineedit_bas_hesap_ismi->setText ( sql_query.VALUE(1).toString() );

            }


            sql_query.PREPARE_SELECT("muh_hesaplar" , "tam_hesap_kodu,hesap_ismi" , "parent_id = :parent_id");
            sql_query.SET_VALUE(":parent_id" , 0);

            if ( sql_query.SELECT("tam_hesap_kodu DESC" , 0 , 1) > 0 ) {
                 sql_query.NEXT();
                m_ui->search_edit_bts_hesabi->SET_TEXT ( sql_query.VALUE(0).toString() );
                m_ui->lineedit_bts_hesap_ismi->setText ( sql_query.VALUE(1).toString() );
            }
            m_ui->frame_hesap_araligi->setDisabled ( true );
        }
        else {
            m_ui->frame_hesap_araligi->setEnabled ( true );
            SET_FOCUS( m_ui->search_edit_bas_hesabi );
        }
    }
    else if ( object EQ m_ui->checkbox_tarih_araligi ) {

        if ( m_ui->checkbox_tarih_araligi->isChecked() EQ false ) {
            m_ui->frame_tarih_araligi->setDisabled ( true );

            m_ui->adakDate_baslangic_tarihi->SET_DATE(MALI_YIL_FIRST_DATE());
            m_ui->adakDate_bitis_tarihi->SET_DATE(MALI_YIL_FIRST_DATE());

        }
        else {
            m_ui->frame_tarih_araligi->setEnabled ( true );
            SET_FOCUS( m_ui->adakDate_baslangic_tarihi);
        }
    }
    else if (object EQ m_ui->combo_box_sayfa_boyutu) {
        int page_id = GET_PAPERSIZE_ENUM ( m_ui->combo_box_sayfa_boyutu->currentText() );
        QPrinter printer;
        printer.setPaperSize((QPrinter::PaperSize)page_id);
        QSizeF size = printer.paperSize(QPrinter::Millimeter);
        m_ui->comma_edit_genisligi->SET_DOUBLE(size.width());
        m_ui->comma_edit_yuksekligi->SET_DOUBLE(size.height());
    }
    else if (object EQ m_ui->comma_edit_genisligi OR m_ui->comma_edit_yuksekligi ) {
        m_ui->combo_box_sayfa_boyutu->setCurrentIndex(-1);
    }
    else if ( object EQ m_ui->adakDate_baslangic_tarihi OR object EQ m_ui->adakDate_bitis_tarihi ) {
        DATE_FRAME_AYARLA ( false );
    }
    else if ( object EQ m_ui->search_edit_bas_hesabi ) {

        sql_query.PREPARE_SELECT("muh_hesaplar" , "hesap_ismi" , "tam_hesap_kodu = :tam_hesap_kodu");
        sql_query.SET_VALUE      ( ":tam_hesap_kodu" , m_ui->search_edit_bas_hesabi->GET_TEXT() );

        if ( sql_query.SELECT() EQ 0 ) {
            MSG_WARNING(  tr("Hesap kodu bulunamadı." ), m_ui->search_edit_bas_hesabi );

            return ADAK_FAIL;
        }
        sql_query.NEXT();

        m_ui->lineedit_bas_hesap_ismi->setText ( sql_query.VALUE(0).toString() );

    }
    else if ( object EQ m_ui->search_edit_bts_hesabi ) {

        sql_query.PREPARE_SELECT("muh_hesaplar" , "hesap_ismi" , "tam_hesap_kodu = :tam_hesap_kodu");
        sql_query.SET_VALUE      ( ":tam_hesap_kodu" , m_ui->search_edit_bts_hesabi->GET_TEXT() );

        if ( sql_query.SELECT() EQ 0 ) {
            MSG_WARNING(  tr ( "Hesap kodu bulunamadı." ), m_ui->search_edit_bts_hesabi );

            return ADAK_FAIL;
        }
        sql_query.NEXT();

        m_ui->lineedit_bts_hesap_ismi->setText ( sql_query.VALUE(0).toString() );
    }
    return ADAK_OK;
}
开发者ID:ArGeMaNiA,项目名称:K9,代码行数:93,代码来源:muh_defteri_kebir_batch.cpp

示例6: CHECK_VAR

int MUH_YEVMIYE_DOKUMU_BATCH::CHECK_VAR ( QObject * object )
{
    if (object EQ m_ui->combo_box_sayfa_boyutu) {
        int page_id = GET_PAPERSIZE_ENUM ( m_ui->combo_box_sayfa_boyutu->currentText() );
        QPrinter printer;
        printer.setPaperSize((QPrinter::PaperSize)page_id);
        QSizeF size = printer.paperSize(QPrinter::Millimeter);
        m_ui->comma_edit_genisligi->SET_DOUBLE(size.width());
        m_ui->comma_edit_sayfa_yuksekligi->SET_DOUBLE(size.height());
    }

    if (object EQ m_ui->comma_edit_genisligi OR m_ui->comma_edit_sayfa_yuksekligi ) {
        m_ui->combo_box_sayfa_boyutu->setCurrentIndex(-1);
    }

    if ( object EQ m_ui->adak_date_bas_tarihi OR object EQ m_ui->adak_date_bts_tarihi ) {
        DATE_FRAME_AYARLA ( false );
    }
    else if ( object EQ m_ui->search_edit_baslangic_yevmiye_no ) {
        QRegExp non_digit ( " ( \\D+ ) " );
        if ( m_ui->search_edit_baslangic_yevmiye_no->GET_TEXT().contains ( non_digit ) EQ true ) {
            MSG_WARNING( tr ( "Yevmiye numarasına rakam dışında bir giriş yapılamaz" ), m_ui->search_edit_baslangic_yevmiye_no );

            return ADAK_FAIL;
        }

        YEVMIYE_NO_FRAME_AYARLA ( false );
    }
    else if ( object EQ m_ui->search_edit_bitis_yevmiye_no  ) {

        QRegExp non_digit ( " (\\D+) " );

        if ( m_ui->search_edit_bitis_yevmiye_no->GET_TEXT().contains ( non_digit ) EQ true ) {
            MSG_WARNING( tr ( "Yevmiye numarasına rakam dışında bir giriş yapılamaz" ), m_ui->search_edit_bitis_yevmiye_no );

            return ADAK_FAIL;
        }

        YEVMIYE_NO_FRAME_AYARLA ( false );
    }

    if ( object EQ m_ui->checkbox_tarih_araligi ) {
        if ( m_ui->checkbox_tarih_araligi->isChecked() EQ false ) {
             m_ui->frame_tarih_araligi->setDisabled ( true );
             m_ui->frame_yevmiye_no_araligi->setEnabled ( true );
             m_ui->checkbox_yvm_no_araligi->setChecked ( true );
             YEVMIYE_NO_FRAME_AYARLA();
        }
        else {
            m_ui->frame_tarih_araligi->setEnabled ( true );
            m_ui->frame_yevmiye_no_araligi->setDisabled ( true );
            m_ui->checkbox_yvm_no_araligi->setChecked ( false );
            DATE_FRAME_AYARLA();
            SET_FOCUS( m_ui->adak_date_bas_tarihi );
        }
    }

    if ( object EQ m_ui->checkbox_sadece_ana_hesaplari_goster ) {
        if (m_ui->checkbox_sadece_ana_hesaplari_goster->isChecked() EQ false ) {
            m_ui->frame_ozet->setDisabled ( true );
            SET_FOCUS( m_ui->search_edit_baslangic_yevmiye_no );
        }
        else {
            m_ui->frame_ozet->setDisabled ( false );
        }
    }

    if ( object EQ m_ui->checkbox_yvm_no_araligi ) {
        if ( m_ui->checkbox_yvm_no_araligi->isChecked() EQ false ) {
             m_ui->search_edit_baslangic_yevmiye_no->SET_TEXT ( "1" );
             m_ui->search_edit_bitis_yevmiye_no->SET_TEXT ( "" );
            m_ui->frame_yevmiye_no_araligi->setDisabled ( true );
            m_ui->frame_tarih_araligi->setEnabled ( true );
            m_ui->checkbox_tarih_araligi->setChecked ( true );
            DATE_FRAME_AYARLA();
        }
        else {
            m_ui->frame_yevmiye_no_araligi->setEnabled ( true );
            m_ui->frame_tarih_araligi->setEnabled ( false );
            m_ui->checkbox_tarih_araligi->setChecked ( false);
            YEVMIYE_NO_FRAME_AYARLA();
            SET_FOCUS( m_ui->search_edit_baslangic_yevmiye_no );
        }
    }
    return ADAK_OK;
}
开发者ID:adakteknoloji,项目名称:E9,代码行数:86,代码来源:muh_yevmiye_dokumu_batch.cpp


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