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


C++ QPrintDialog类代码示例

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


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

示例1: greaterThan

void MainWindow::on_pushButton_clicked()
{
    /* To use this function, add these includes:
     *
    #include <QPrinter>
    #include <QPrintDialog>
    #include <QPainter>
     *
     *
     Change '.pro' file to include these lines:

        greaterThan(QT_MAJOR_VERSION, 4){
         QT += widgets
         QT += printsupport
        }
     *
     *
     */
    QPrinter printer;

    QPrintDialog *dialog = new QPrintDialog(&printer, this);
    dialog->setWindowTitle(tr("Print Document"));

    if (dialog->exec() != QDialog::Accepted)
        return;

    QPixmap pixmap = QPixmap::grabWidget(test, 0, 0, -1, -1);
    QPainter painter;
    painter.begin(&printer);
    painter.drawImage(0, 0, pixmap.toImage());
    painter.end();
}
开发者ID:james007crocker,项目名称:V3_Submission_Dec9th,代码行数:32,代码来源:Print.cpp

示例2: QPrintDialog

void
message_view::print()
{
  QPrinter printer;
  QPrintDialog *dialog = new QPrintDialog(&printer, this);
  dialog->setWindowTitle(tr("Print Document"));
  if (dialog->exec() != QDialog::Accepted)
    return;

  delete dialog;
  m_pmsg->fetch_body_text(false);
  QString html_body = m_bodyv->page()->mainFrame()->toHtml();

  mail_displayer disp(this);
  body_view* printview = new body_view(NULL);
  printview->set_mail_item(m_bodyv->mail_item());
  printview->display(html_body);

  const struct display_prefs& prefs = m_parent->get_display_prefs();
  QString h = disp.sprint_headers(prefs.m_show_headers_level, m_pmsg);
  QString hmore = disp.sprint_additional_headers(prefs, m_pmsg);
  h.append(hmore);
  printview->prepend_body_fragment(h);

  printview->print(&printer);
  delete printview;
}
开发者ID:AleksKots,项目名称:Manitou,代码行数:27,代码来源:message_view.cpp

示例3: QTextDocument

bool ignsystem::print(const QVariant &config){
    QVariantMap conf = jsonParse->jsonParser(config).toVariantMap();
    QPrinter print;
    QTextDocument *doc = new QTextDocument();

    QString type = conf["type"].toString();
    QString txt = conf["content"].toString();
    QString out = conf["out"].toString();

    if(type == "html")
    {
        doc->setHtml(txt);
    }
    else
    {
        doc->setPlainText(txt);
    }

    if(out == "pdf"){
        print.setOutputFormat(QPrinter::PdfFormat);
    }

    QPrintDialog *dialog = new QPrintDialog(&print);
    if (dialog->exec() != QDialog::Accepted)
    {
        return false;
    }
    else
    {
        doc->print(&print);
        delete doc;
        return true;
    }
}
开发者ID:aksaramaya,项目名称:ignsdk-qt,代码行数:34,代码来源:ignsystem.cpp

示例4: printer

bool XmlPdf::print(QString file) {
	QPrinter printer(QPrinter::HighResolution);
	printer.setPaperSize(paperSize);
	printer.setOrientation(paperOrientation);
	printer.setOutputFormat(QPrinter::PdfFormat);
	printer.setPageMargins(8.53, 8.53, 3.53, 3.53, QPrinter::Millimeter);
	
	if (file.isEmpty()) {
		QPrintDialog *dialog = new QPrintDialog(&printer);
		dialog->setWindowTitle(QObject::tr("Print Document"));
		if (dialog->exec() != QDialog::Accepted) {
			qDebug() << "Printing aborted and no Filename given, canceled printing...";
			return false;
		}
	} else {
		printer.setOutputFileName(file);
	}
	
	QPainter *painter = new QPainter();
	if (!painter->begin(&printer)) {
		qDebug() << QString("The File is not writable:\n%1").arg(file);
		return false;
	}
	
	addDynamics(painter, &printer);
	addStatics(painter);
	painter->end();
	return true;
}
开发者ID:LukyLuke,项目名称:PiTres,代码行数:29,代码来源:XmlPdf.cpp

示例5: QPrintDialog

//Print clicked, format all lists
//for printing
void TaskList_Main::printAllClick(){
    QPrinter printer;

    //Create new print dialog (select printer)
    QPrintDialog *pDialog = new QPrintDialog(&printer, this);
    pDialog->setWindowTitle(tr("Print Document"));
    if(pDialog->exec() != QDialog::Accepted)
        return;
    else{
        QTextDocument document;
        QString html = "";

        for(int i = 0; i < listPane->mainList->count(); ++i){
            QListWidgetItem *currList = listPane->mainList->item(i);
            my_listwidget *currNote = notePane->listMap[currList];

            //Generate HTML driven output
            html += "<font size=\"7\"><b>" + currList->text() + "</b></font><br />";
            for(int i = 0; i < currNote->count(); i++){
                if(currNote->item(i)->flags() != 0)
                    html += "<font size=\"5\">" + currNote->item(i)->text() + "</font><br />";
                else
                    html += "--<font size=\"4\"><i>" + currNote->item(i)->text() + "</i></font><br />";
            }

            html += "<br />";
        }

        //Set document's HTML info
        document.setHtml(html);

        //Print the HTML text
        document.print(&printer);
    }
}
开发者ID:ep3998,项目名称:Tasklist493---Test,代码行数:37,代码来源:tasklist_main.cpp

示例6: QTextDocument

bool ignsystem::print(const QVariant &config) {
  QVariantMap configuration = jsonParse->jsonParser(config).toVariantMap();
  QPrinter printer;
  QTextDocument *document = new QTextDocument();
  QPrintDialog *printDialog = new QPrintDialog(&printer);

  QString type = configuration[QStringLiteral("type")].toString();
  QString content = configuration[QStringLiteral("content")].toString();
  QString output = configuration[QStringLiteral("out")].toString();

  if (type == QLatin1String("html")) {
    document->setHtml(content);
  } else {
    document->setPlainText(content);
  }

  if (output == QLatin1String("pdf")) {
    printer.setOutputFormat(QPrinter::PdfFormat);
  }

  if (printDialog->exec() == QDialog::Accepted) {
    document->print(&printer);
    delete document;
    return true;
  } else {
    return false;
  }
}
开发者ID:ubunteroz,项目名称:ignsdk-debian,代码行数:28,代码来源:system.cpp

示例7: QPrintDialog

void DocDisplayWindow::on_actionPrint_triggered()
{
     QPrinter printer;
     QPrintDialog *dialog = new QPrintDialog(&printer, this);
         if (dialog->exec() != QDialog::Accepted)
             return;
         ui->docDisplay->print(&printer);
}
开发者ID:TheMontezuma,项目名称:RespeQt,代码行数:8,代码来源:docdisplaywindow.cpp

示例8: printer

void PringKvitok::on_toolButton_print_clicked()
{
#if !defined(QT_NO_PRINTER)

    QPrinter printer(QPrinter::HighResolution);
    QPrintDialog *dlg = new QPrintDialog(&printer, this);

   dlg->setWindowTitle(tr("Настройки принтера"));
   if (dlg->exec() == QDialog::Accepted){
       QString pg;
       QMapIterator<QString, QCheckBox*> i(childsCheckBox_map);
       ui->progressBar->setVisible(true);
       int count = 0;
       int c = 0;
       while (i.hasNext()) {
           i.next();
            QCheckBox *cb = i.value();
            if (cb->checkState() == Qt::Checked){
                count++;
             }
       }

       ui->progressBar->setMaximum(count);
       QString page1;
       QString page2;
       while (i.hasPrevious()) {
           i.previous();
           QCheckBox *cb = i.value();

            if (cb->checkState() == Qt::Checked){
                if (ui->checkBox_twokv->checkState() == Qt::Checked){
                if (page1 == "") page1 = prepareKvit(cb->text());
                else {
                   page2 = prepareKvit(cb->text());
                   pg += TwoKvitOnePage(page1, page2);
                   page1 = "";
                   page2 = "";
                }
             } else pg += prepareKvit(cb->text());
             ui->progressBar->setValue(c++);
           }

       }
       if (ui->checkBox_twokv->checkState() == Qt::Checked && page1 != "" && page2 == "") pg += page1;
        QTextDocument textDocument;

        textDocument.setHtml(pg);
         QPrinter printer(QPrinter::HighResolution);
         printer.setOrientation(QPrinter::Portrait);
         printer.setPaperName("A4");
         printer.setPageMargins(0.3, 0.3, 0.3, 0.3, QPrinter::Unit() );
         if (ui->checkBox_duplex->checkState() == Qt::Checked)printer.setDuplex(QPrinter::DuplexAuto);
         textDocument.print(&printer);
          ui->progressBar->setVisible(false);
   }
   delete dlg;
 #endif
}
开发者ID:haltxz,项目名称:ds,代码行数:58,代码来源:pringkvitok.cpp

示例9: QPrintDialog

QPrintDialog *KdePrint::createPrintDialog(QPrinter *printer, const QList<QWidget *> &customTabs, QWidget *parent)
{
    QPrintDialog *dialog = new QPrintDialog(printer, parent);
#if defined(Q_OS_UNIX) && !defined(Q_OS_DARWIN)
    dialog->setOptionTabs(customTabs);
#else //Not Unix modulo Mac
    foreach (QWidget *w, customTabs) { // reparent to avoid leaks
        w->setParent(dialog);
    }
开发者ID:KDE,项目名称:kdelibs4support,代码行数:9,代码来源:kdeprintdialog.cpp

示例10: QPrintDialog

//! Print the checked in and missing items.
void wndInventoryCheck::printReport( void )
{
    QPrinter printer;
    printer.setPaperSize( QPrinter::Letter );
    printer.setPageMargins( 1, 1, 1, 1, QPrinter::Inch );

    QPrintDialog *dialog = new QPrintDialog( &printer, this );
    if ( dialog->exec() != QDialog::Accepted )
    {
        return;
    }

    // PDF printing:
    //printer.setOutputFormat(QPrinter::PdfFormat);
    //printer.setOutputFileName("test.pdf");

    // Build the painter data which is printed
    QPainter painter;

    if ( !painter.begin( &printer ) ) // Link the painter to the printer
    {
        qWarning("Printer Error: Could not link painter to printer. ");
        return;
    }

    painter.setFont( QFont( "Courier New", 12, QFont::Bold ) );

    int pw = (int)( printer.pageRect( QPrinter::DevicePixel ).width() );
    int ph = (int)( printer.pageRect( QPrinter::DevicePixel ).height() );
    int y = 0;
    painter.drawText( 0, 0, pw, ph, Qt::AlignHCenter, "Station 40 - Youngsville Fire Department\n"
                     "Inventory Audit Report\n"  + QDate::currentDate().toString( "dddd the d of MMMM yyyy" ) );
    y = 80;
    if ( _pUI->chkCheckedItems->isChecked() )
    {
        painter.drawText( 0, y, pw, ph, Qt::AlignLeft, "Checked Items" );
        y += 20;

        for ( int i = 0; i < _pUI->tblCheckedIn->model()->rowCount(); i++ )
        {
            painter.drawText( 20, y, pw, ph, Qt::AlignLeft, _pUI->tblCheckedIn->model()->index( i, 1 ).data().toString() );
            y += 20;
        }
    }

    if ( _pUI->chkMissingItems->isChecked() )
    {
        painter.drawText( 0, y, pw, ph, Qt::AlignLeft, "Missing Items" );
        y += 20;
        for ( int i=0; i < _pUI->tblNotCheckedIn->model()->rowCount(); i++ )
        {
            painter.drawText( 20, y, pw, ph, Qt::AlignLeft, _pUI->tblNotCheckedIn->model()->index( i, 1 ).data().toString() );
            y += 20;
        }
    }
    painter.end();
}
开发者ID:JDougherty,项目名称:Fire-Department-Management-System,代码行数:58,代码来源:wndinventorycheck.cpp

示例11: printer

void MainWindow::printPdf()
{
    QPrinter printer(QPrinter::HighResolution);
    printer.setOutputFormat(QPrinter::PdfFormat);

    QPrintDialog *printDialog = new QPrintDialog(&printer, this);
    if (printDialog->exec() == QDialog::Accepted)
        editor->document()->print(&printer);
}
开发者ID:Andreas665,项目名称:qt,代码行数:9,代码来源:mainwindow.cpp

示例12: QObject

CPrint::CPrint(QObject *parent) : QObject(parent)
{
    QTextDocument doc;
    QTextCursor cur(&doc);

    //TEMP
    QPrintDialog dlg;
    dlg.show();
}
开发者ID:fblabs,项目名称:cimiapp2,代码行数:9,代码来源:cprint.cpp

示例13: QPrintDialog

void QgsIdentifyResultsWebView::print( void )
{
  QPrinter printer;
  QPrintDialog *dialog = new QPrintDialog( &printer );
  if ( dialog->exec() == QDialog::Accepted )
  {
    QWebView::print( &printer );
  }
}
开发者ID:VKa,项目名称:Quantum-GIS,代码行数:9,代码来源:qgsidentifyresultsdialog.cpp

示例14: currentTab

void MainWindow::print()
{
  if(currentTab()->availableActions() && AbstractTabWidget::Print)
  {
    QPrinter *printer = currentTab()->printer();
    QPrintDialog *printDialog = new QPrintDialog(printer, this);
    if(printDialog->exec() == QDialog::Accepted)
      currentTab()->print();
  }
}
开发者ID:thibault7249,项目名称:dbmaster,代码行数:10,代码来源:mainwindow.cpp

示例15: QPrinter

void PhotoLayoutsEditor::print()
{
    QPrinter * printer = new QPrinter();
    m_canvas->preparePrinter(printer);
    QPrintDialog * dialog = new QPrintDialog(printer, this);
    connect(dialog, SIGNAL(accepted(QPrinter*)), m_canvas, SLOT(renderCanvas(QPrinter*)));
    dialog->exec();
    delete dialog;
    delete printer;
}
开发者ID:tejastank,项目名称:kipi-plugins,代码行数:10,代码来源:photolayoutseditor.cpp


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