本文整理汇总了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();
}
示例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;
}
示例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;
}
}
示例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;
}
示例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);
}
}
示例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;
}
}
示例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);
}
示例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
}
示例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);
}
示例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();
}
示例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);
}
示例12: QObject
CPrint::CPrint(QObject *parent) : QObject(parent)
{
QTextDocument doc;
QTextCursor cur(&doc);
//TEMP
QPrintDialog dlg;
dlg.show();
}
示例13: QPrintDialog
void QgsIdentifyResultsWebView::print( void )
{
QPrinter printer;
QPrintDialog *dialog = new QPrintDialog( &printer );
if ( dialog->exec() == QDialog::Accepted )
{
QWebView::print( &printer );
}
}
示例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();
}
}
示例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;
}