本文整理汇总了C++中QPrintPreviewDialog类的典型用法代码示例。如果您正苦于以下问题:C++ QPrintPreviewDialog类的具体用法?C++ QPrintPreviewDialog怎么用?C++ QPrintPreviewDialog使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QPrintPreviewDialog类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QPrintPreviewDialog
void EditDialog::openPrintDialog()
{
QPrinter printer;
QPrintPreviewDialog *dialog = new QPrintPreviewDialog(&printer);
QTextDocument *document = new QTextDocument();
switch (dataSource) {
case TextBuffer:
document->setPlainText(ui->editorText->toPlainText());
break;
case SciBuffer:
// This case isn't really expected because the Scintilla widget has it's own printing slot
document->setPlainText(sciEdit->text());
break;
case HexBuffer:
document->setPlainText(hexEdit->toReadableString());
document->setDefaultFont(hexEdit->font());
break;
}
connect(dialog, &QPrintPreviewDialog::paintRequested, [&](QPrinter *previewPrinter) {
document->print(previewPrinter);
});
dialog->exec();
delete dialog;
delete document;
}
示例2: QPrintPreviewDialog
void ExportWizard::slotPdfPreview()
{
QPrintPreviewDialog *previewDialog = new QPrintPreviewDialog(m_pdfPrinter, this);
connect(previewDialog, SIGNAL(paintRequested(QPrinter*)), this, SLOT(printPdf()));
previewDialog->exec();
delete previewDialog;
}
示例3: tr
void OtchetStudenty::on_pushButton_showReport_clicked()
{
MyPrint myPrint;
RowList list;
list[5] = tr("Специальность");
list[6] = tr("Группа");
list[7] = tr("Ф-а оплаты");
list[8] = tr("ФИО");
if(ui->checkBox1->isChecked())
list[9] = tr("Ф-а обучения");
if(ui->checkBox2->isChecked())
list[10] = tr("Дата рождения");
if(ui->checkBox3->isChecked())
list[11] = tr("Телефон");
if(ui->checkBox4->isChecked())
list[12] = tr("Email");
if(ui->checkBox5->isChecked())
list[13] = tr("Дата пост.");
if(ui->checkBox6->isChecked())
list[14] = tr("Паспорт");
if(ui->checkBox7->isChecked())
list[15] = tr("Телефоны род.");
if(ui->checkBox8->isChecked())
list[16] = tr("Email род.");
if(ui->checkBox9->isChecked())
list[17] = tr("Адрес прож-я");
if(ui->checkBox10->isChecked())
list[18] = tr("Адрес прописки");
if(ui->checkBox11->isChecked())
list[19] = tr("Школа");
QLayoutItem* item;
while ((item = ui->verticalLayout->takeAt(0) ) != NULL )
{
delete item->widget();
delete item;
}
body = myPrint.print(dal_studentsControl->getStudentsReport(ui->comboBox_spec->model()->index(ui->comboBox_spec->currentIndex(),0).data().toInt(),
ui->comboBox_gruppa->model()->index(ui->comboBox_gruppa->currentIndex(),0).data().toInt(),
ui->dateEdit_start->date(),
ui->dateEdit_end->date(),
ui->comboBox_formaObuc->model()->index(ui->comboBox_formaObuc->currentIndex(),0).data().toInt(),
ui->comboBox_formaOplaty->model()->index(ui->comboBox_formaOplaty->currentIndex(),0).data().toInt()),
list,
this->windowTitle(), "", 3);
QPrinter printer(QPrinter::HighResolution);
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setOutputFileName("file.pdf");
QPrintPreviewDialog *preview = new QPrintPreviewDialog (&printer);
preview->setAttribute(Qt::WA_DeleteOnClose);
preview->setWindowFlags(Qt::Widget);
QList<QPrintPreviewWidget*> list2 = preview->findChildren<QPrintPreviewWidget*>();
if(!list2.isEmpty())
list2.first()->setZoomMode(QPrintPreviewWidget::FitToWidth);
connect(preview, SIGNAL(paintRequested(QPrinter *)), SLOT(printDocument(QPrinter *)));
ui->verticalLayout->addWidget(preview);
on_pushButton_graph_clicked();
preview->exec();
}
示例4: QPrintPreviewDialog
void tab::printPage(QWebFrame *frame)
{
QPrintPreviewDialog *dialog = new QPrintPreviewDialog(this);
dialog->resize(800, 600);
connect(dialog, SIGNAL(paintRequested(QPrinter*)), frame, SLOT(print(QPrinter*)));
dialog->exec();
dialog->deleteLater();
}
示例5: LogEx
//add by KeoJam 增加打印接口
void LxDialogBase::printPreview()
{
LogEx("void LomoX::printPreview()");
if (!m_ptrWebView)
return;
QPrintPreviewDialog *dialog = new QPrintPreviewDialog(m_ptrWebView);
dialog->setAttribute(Qt::WA_DeleteOnClose);
connect(dialog, SIGNAL(paintRequested(QPrinter*)),
m_ptrWebView, SLOT(print(QPrinter*)));
dialog->exec();
}
示例6: printer
void Overhead::printDialog()
{
QPrinter printer(QPrinter::HighResolution);
//printer.setResolution(QPrinter::A4);
printer.setPaperSize(QPrinter::A4);
//printer.setOrientation(QPrinter::Portrait);
QPrintPreviewDialog *pd = new QPrintPreviewDialog(&printer);
connect(pd, SIGNAL(paintRequested(QPrinter*)),
this, SLOT(printDriver(QPrinter*)));
pd->exec();
}
示例7: QPrinter
void PhotoLayoutsEditor::printPreview()
{
if (m_canvas && m_canvas->scene())
{
QPrinter * printer = new QPrinter();
m_canvas->preparePrinter(printer);
QPrintPreviewDialog * dialog = new QPrintPreviewDialog(printer, this);
connect(dialog, SIGNAL(paintRequested(QPrinter*)), m_canvas, SLOT(renderCanvas(QPrinter*)));
dialog->exec();
delete dialog;
delete printer;
}
}
示例8: if
// ---------------------------------------------------------------------
void Editm::cmd(string p,string v)
{
QStringList opt=qsplit(v);
if (p=="print") {
#ifndef QT_NO_PRINTER
((EditmPTE*) widget)->printPreview(config.Printer);
#endif
} else if (p=="printpreview") {
#ifndef QT_NO_PRINTER
QPrintPreviewDialog *dlg = new QPrintPreviewDialog(config.Printer, pform);
dlg->setWindowTitle("Preview Document");
QObject::connect(dlg,SIGNAL(paintRequested(QPrinter *)),((EditmPTE*) widget),SLOT(printPreview(QPrinter *)));
dlg->exec();
delete dlg;
config.Printer->setPrintRange(QPrinter::AllPages);
#endif
} else Child::set(p,v);
示例9: tr
void JurnalVzaimoposesheniya::on_pushButtonPrint_clicked()
{
MyPrint myPrint;
RowList list;
QString title = this->windowTitle();
list[5] = tr("ФИО преподавателя");
list[6] = tr("Вид дисциплины");
list[7] = tr("Дисциплина");
list[8] = tr("Группа");
list[9] = tr("Дата посещения");
list[10] = tr("Отзыв");
list[11] = tr("Проверяющий");
list[12] = tr("Оценка");
QString prover = ui->tableView_jurnalVzaimopos->model()->index(0,11).data().toString();
JurnalVzaimoposModels = dal_studentsControl->getJurnVzaimopos(this->fioProver, this->dateBeginning, this->dateEnd );
ui->tableView_jurnalVzaimopos->setModel(JurnalVzaimoposModels);
body = myPrint.print((QSqlQueryModel*)JurnalVzaimoposModels, list, "Журнал взаимопосещения на " + ui->dateEdit->date().toString("yyyy") + " - " + ui->dateEdit_end->date().toString("yyyy") + " учебный год", "Подпись проверяющего ( " + prover + " ):____________________________________", 0);
QPrinter printer(QPrinter::HighResolution);
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setOutputFileName("file.pdf");
QPrintPreviewDialog *preview = new QPrintPreviewDialog (&printer);
preview->setAttribute(Qt::WA_DeleteOnClose);
preview->setWindowFlags(Qt::Widget);
QList<QPrintPreviewWidget*> list2 = preview->findChildren<QPrintPreviewWidget*>();
if(!list2.isEmpty()) // paranoiac safety check
list2.first()->setZoomMode(QPrintPreviewWidget::FitToWidth);
connect(preview, SIGNAL(paintRequested(QPrinter *)), SLOT(printDocument(QPrinter *)));
QLayoutItem* item;
// while ((item = ui->verticalLayout->takeAt(0) ) != NULL )
// {
// delete item->widget();
// delete item;
// }
// ui->verticalLayout->addWidget(preview);
preview->exec();
}
示例10: printer
void addoredir_raspisanie::on_pushButton_print_clicked()
{
if(ui->comboBox_sotr->currentIndex()==-1)
{
return;
}
body = "";
body += "<H2>Расписание " + ui->comboBox_sotr->currentText() + "</H2>";
body += "<table border=\"1\">";
body += "<tr><td>Время</td>";
for (int k = 0; k < days.count(); k++)
body += "<td align=\"center\" valign = \"middle\" style=\"padding:3px;\"><b>" + days.at(k) + "</b></td>";
body += "</tr>";
for (int vr = 1; vr < 7; vr++)
{
body += "<tr>";
body += "<td align=\"center\" valign = \"middle\" style=\"padding:3px;\"><b>" + ui->tableWidget_rasp->item(vr, 0)->text() + "</b></td>";// время
for (int den = 1; den < 7; den++)
{
body += "<td style=\"padding:3px;\">" + ui->tableWidget_rasp->item(vr, den)->text() + "</td>";
}
body += "</tr>";
}
body += "</table>";
// QPrinter printer(QPrinter::HighResolution);
// printer.setOrientation(QPrinter::Portrait);
// printer.setPaperSize(QPrinter::A4);
// printer.setFullPage(true);
QPrinter printer(QPrinter::HighResolution);
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setOutputFileName("file.pdf");
QPrintPreviewDialog *preview = new QPrintPreviewDialog (&printer);
preview->setAttribute(Qt::WA_DeleteOnClose);
preview->setWindowTitle("Печать");
preview->setWindowFlags(Qt::Window);
connect(preview, SIGNAL(paintRequested(QPrinter *)), SLOT(printDocument(QPrinter *)));
preview->exec();
}
示例11: QT_VERSION_CHECK
void TextPrinter::preview(const QTextDocument *document,
const QString &caption)
{
#if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0))
if (!document) return;
QPrintPreviewDialog *dialog = new QPrintPreviewDialog(printer_, parent_);
dialog->setWindowTitle(caption.isEmpty() ? "Print Preview" : caption);
connect(dialog, SIGNAL(paintRequested(QPrinter*)),
this, SLOT(print(QPrinter*)));
// preview it
tempdoc_ = document->clone();
dialog->exec();
delete tempdoc_;
tempdoc_ = 0;
delete dialog;
#endif
}
示例12: QPrintPreviewDialog
void MainWindow::previewReady()
{
QPrintPreviewDialog * pre = new QPrintPreviewDialog(render->getPrinter(),this);
connect(pre, SIGNAL(paintRequested(QPrinter*)), render, SLOT(Print(QPrinter*)));
pre->show();
}
示例13: tr
//.........这里部分代码省略.........
list[7] = tr("Off-line");
if(ui->checkBox7->isChecked())
list[8] = tr("Контр. раб.");
if(ui->checkBox8->isChecked())
list[9] = tr("Экзам.");
if(ui->checkBox9->isChecked())
list[10] = tr("Курс. раб.");
if(ui->checkBox10->isChecked())
list[11] = tr("Язык");
if(ui->checkBox11->isChecked())
list[12] = tr("Номер справки");
if(ui->checkBox12->isChecked())
list[13] = tr("Всего");
QString header = this->windowTitle() + "<br><br>" \
"<H3>На " + ui->dateEdit_startReport->date().toString("MMMM yyyy") + " г. </H3>";
if(!ui->checkBox_detalno->isChecked())
{
toPrint = myPrint.print(dal_prepodcontrol->getSpravkiPochasReport(ui->comboBox_sotr->model()->index(ui->comboBox_sotr->currentIndex(),0).data().toInt(),
ui->dateEdit_startReport->date()),
list, header, "", 0);
}
else
{
QSqlQueryModel* modelMain = dal_prepodcontrol->getSpravkiPochasReport(ui->comboBox_sotr->model()->index(ui->comboBox_sotr->currentIndex(),0).data().toInt(),
ui->dateEdit_startReport->date());
QString body;
body.append("<html><head>"
"<link rel='stylesheet' type='text/css' href='format.css'>"
"</head><body>");
body.append("<center><H2>" + header + "</H2></center><br>");
RowList list2;
list2[0] = tr("Дата");
list2[1] = tr("Группа");
list2[2] = tr("Дисциплина");
if(ui->checkBox2->isChecked())
list2[3] = tr("Лекций");
if(ui->checkBox3->isChecked())
list2[4] = tr("Лабор.");
if(ui->checkBox4->isChecked())
list2[5] = tr("Практич.");
if(ui->checkBox5->isChecked())
list2[6] = tr("On-line");
if(ui->checkBox6->isChecked())
list2[7] = tr("Off-line");
if(ui->checkBox7->isChecked())
list2[8] = tr("Контр. раб.");
if(ui->checkBox8->isChecked())
list2[9] = tr("Экзам.");
if(ui->checkBox9->isChecked())
list2[10] = tr("Курс. раб.");
for (int i = 0; i < modelMain->rowCount(); ++i)
{
body.append("<p><b>" + modelMain->record(i).value(1).toString() + "</b></p><hr>");
body.append(myPrint.printOnlyTable(dal_prepodcontrol->getSpravkaPochasDetails(modelMain->record(i).value(14).toInt()), list2, 0));
body.append("<p><H3>Итого: всего: " + modelMain->record(i).value(13).toString() + "</H3>");
if(ui->checkBox2->isChecked())
body.append(" лекций: " + modelMain->record(i).value(3).toString());
if(ui->checkBox3->isChecked())
body.append(" лабор.: " + modelMain->record(i).value(4).toString());
if(ui->checkBox4->isChecked())
body.append(" прак.: " + modelMain->record(i).value(5).toString());
if(ui->checkBox5->isChecked())
body.append(" on-line: " + modelMain->record(i).value(6).toString());
if(ui->checkBox6->isChecked())
body.append(" off-line: " + modelMain->record(i).value(7).toString());
if(ui->checkBox7->isChecked())
body.append(" контр. раб.: " + modelMain->record(i).value(8).toString());
if(ui->checkBox8->isChecked())
body.append(" экзамен.: " + modelMain->record(i).value(9).toString());
if(ui->checkBox9->isChecked())
body.append(" курс. раб.: " + modelMain->record(i).value(10).toString());
body.append("</p>");
body.append("<br>");
}
body.append("</body></html>");
QTextDocument *toPrint2 = new QTextDocument;
toPrint2->addResource(QTextDocument::StyleSheetResource, QUrl( "format.css" ), css->reportCss);
toPrint2->setHtml(body);
toPrint = toPrint2;
}
QPrinter printer(QPrinter::HighResolution);
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setOutputFileName("file.pdf");
QPrintPreviewDialog *preview = new QPrintPreviewDialog (&printer);
preview->setAttribute(Qt::WA_DeleteOnClose);
preview->setWindowFlags(Qt::Widget);
QList<QPrintPreviewWidget*> list2 = preview->findChildren<QPrintPreviewWidget*>();
if(!list2.isEmpty()) // paranoiac safety check
list2.first()->setZoomMode(QPrintPreviewWidget::FitToWidth);
connect(preview, SIGNAL(paintRequested(QPrinter *)), SLOT(printDocument(QPrinter *)));
QLayoutItem* item;
while ((item = ui->verticalLayout->takeAt(0) ) != NULL )
{
delete item->widget();
delete item;
}
ui->verticalLayout->addWidget(preview);
preview->exec();
}
示例14: QPrintPreviewDialog
void SoulNote::on_action_PrintPreview_triggered()
{
QPrintPreviewDialog *preview = new QPrintPreviewDialog(m_printer, this);
connect(preview, SIGNAL(paintRequested(QPrinter*)), this, SLOT(preview(QPrinter*)));
preview->exec();
}
示例15: QPrintPreviewDialog
bool Worksheet::printPreview() const {
const WorksheetView* view = reinterpret_cast<const WorksheetView*>(m_view);
QPrintPreviewDialog* dlg = new QPrintPreviewDialog(m_view);
connect(dlg, SIGNAL(paintRequested(QPrinter*)), view, SLOT(print(QPrinter*)));
return dlg->exec();
}