本文整理汇总了C++中QPrintDialog::exec方法的典型用法代码示例。如果您正苦于以下问题:C++ QPrintDialog::exec方法的具体用法?C++ QPrintDialog::exec怎么用?C++ QPrintDialog::exec使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPrintDialog
的用法示例。
在下文中一共展示了QPrintDialog::exec方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: filePrint
void TextEdit::filePrint()
{
#ifndef QT_NO_PRINTER
QPrinter printer(QPrinter::HighResolution);
QPrintDialog *dlg = new QPrintDialog(&printer, this);
if (textEdit->textCursor().hasSelection())
dlg->addEnabledOption(QAbstractPrintDialog::PrintSelection);
dlg->setWindowTitle(tr("Print Document"));
if (dlg->exec() == QDialog::Accepted) {
textEdit->print(&printer);
}
delete dlg;
#endif
}
示例2: slotPrintReport
void KexiReportView::slotPrintReport()
{
QPrinter printer;
ORPrintRender pr;
// do some printer initialization
pr.setPrinter(&printer);
pr.setupPrinter(m_reportDocument, &printer);
QPrintDialog *dialog = new QPrintDialog(&printer, this);
if (dialog->exec() != QDialog::Accepted)
return;
pr.render(m_reportDocument);
}
示例3: QPrintDialog
void Qtilities::CoreGui::MessagesPlainTextEditTab::handle_Print() {
#ifndef QT_NO_PRINTER
QPrinter printer;
QPrintDialog *dialog = new QPrintDialog(&printer, this);
dialog->setWindowTitle(tr("Print Current Log"));
if (d->txtLog.textCursor().hasSelection())
dialog->addEnabledOption(QAbstractPrintDialog::PrintSelection);
if (dialog->exec() != QDialog::Accepted)
return;
delete dialog;
d->txtLog.print(&printer);
#endif
}
示例4: print
void ImageArea::print()
{
QPrinter *printer = new QPrinter();
QPrintDialog *printDialog = new QPrintDialog(printer);
if(printDialog->exec())
{
QPainter painter(printer);
QRect rect = painter.viewport();
QSize size = mImage->size();
size.scale(rect.size(), Qt::KeepAspectRatio);
painter.setViewport(rect.x(), rect.y(), size.width(), size.height());
painter.setWindow(mImage->rect());
painter.drawImage(0, 0, *mImage);
}
}
示例5: print
void MainWindow::print()
{
QPrinter printer;
QPainter painter;
QPrintDialog *dialog = new QPrintDialog(&printer);
dialog->setWindowTitle("Print Document");
if (dialog->exec() != QDialog::Accepted)
return;
painter.begin(&printer);
ui->treeWidget->expandAll();
ui->treeWidget->render(&painter);
ui->treeWidget->collapseAll();
painter.end();
}
示例6: print
void MessageWidget::print()
{
#ifndef QT_NO_PRINTER
QPrinter printer(QPrinter::HighResolution);
printer.setFullPage(true);
QPrintDialog *dlg = new QPrintDialog(&printer, this);
if (ui.msgText->textCursor().hasSelection())
dlg->addEnabledOption(QAbstractPrintDialog::PrintSelection);
dlg->setWindowTitle(tr("Print Document"));
if (dlg->exec() == QDialog::Accepted) {
ui.msgText->print(&printer);
}
delete dlg;
#endif
}
示例7: print
//! [3]
void MainWindow::print()
{
#ifndef QT_NO_PRINTDIALOG
QTextDocument *document = textEdit->document();
QPrinter printer;
QPrintDialog *dlg = new QPrintDialog(&printer, this);
if (dlg->exec() != QDialog::Accepted)
return;
document->print(&printer);
statusBar()->showMessage(tr("Ready"), 2000);
#endif
}
示例8: printThis
void PrintingService::printThis(QTableView *tableToPrint){
QString strStream;
QTextStream out(&strStream);
QString strTitle;
const int rowCount = tableToPrint->model()->rowCount();
const int columnCount = tableToPrint->model()->columnCount();
out << "<html>\n <head>\n <meta Content=\"Text/html; charset=Windows-1251\">\n"
<< QString("<title>%1</title>\n").arg(strTitle)
<< "</head>\n"
"<body bgcolor=#ffffff link=#5000A0>\n"
"<table border=1 cellspacing=0 cellpadding=2>\n";
// headers
out << "<thead><tr bgcolor=#f0f0f0>";
for (int column = columnCount-1; column >= 0 ; column--)
if (!tableToPrint->isColumnHidden(column))
out << QString("<th>%1</th>").arg(tableToPrint->model()->headerData(column, Qt::Horizontal).toString());
out << "</tr></thead>\n";
// data table
for (int row = 0; row < rowCount; row++) {
out << "<tr>";
for (int column = columnCount-1; column >=0 ; column--) {
if (!tableToPrint->isColumnHidden(column)) {
QString data = tableToPrint->model()->data(tableToPrint->model()->index(row, column)).toString().simplified();
out << QString("<td bkcolor=0>%1</td>").arg((!data.isEmpty()) ? data : QString(" "));
}
}
out << "</tr>\n";
}
out << "</table>\n"
"</body>\n"
"</html>\n";
QTextDocument *document = new QTextDocument();
document->setHtml(strStream);
QPrinter printer;
QPrintDialog *dialog = new QPrintDialog(&printer, NULL);
if (dialog->exec() == QDialog::Accepted) {
document->print(&printer);
}
delete document;
}
示例9: print
void QFEHelpEditorWidget::print()
{
#ifndef QT_NO_PRINTER
QPrinter printer;
QPrintDialog *dialog = new QPrintDialog(&printer, this);
dialog->setWindowTitle(tr("Print Document"));
if (ui->edtScript->getEditor()->textCursor().hasSelection())
dialog->addEnabledOption(QAbstractPrintDialog::PrintSelection);
if (dialog->exec() != QDialog::Accepted)
return;
ui->edtScript->getEditor()->print(&printer);
#endif
}
示例10: slotFilePrint
void KMouthApp::slotFilePrint()
{
slotStatusMsg(i18n("Printing..."));
if (printer == 0) {
printer = new QPrinter();
}
QPrintDialog *printDialog = KdePrint::createPrintDialog(printer, this);
if (printDialog->exec()) {
phraseList->print(printer);
}
slotStatusMsg(i18nc("The job is done", "Ready."));
}
示例11: printPdf
void ScribbleArea::printPdf()
{
QPrinter printer(QPrinter::HighResolution);
printer.setOutputFormat(QPrinter::PdfFormat);
QPrintDialog *printDialog = new QPrintDialog(&printer, this);
if (printDialog->exec() == QDialog::Accepted) {
QPainter painter(&printer);
QRect rect = painter.viewport();
QSize size = image.size();
size.scale(rect.size(), Qt::KeepAspectRatio);
painter.setViewport(rect.x(), rect.y(), size.width(), size.height());
painter.setWindow(image.rect());
painter.drawImage(0, 0, image);
}
}
示例12: on_actionPrint_triggered
void MainWindow::on_actionPrint_triggered()
{
QGraphicsScene printScene;
QPixmap img;
QPrinter printer;
QPrintDialog *dialog = new QPrintDialog(&printer, this);
dialog->setWindowTitle("Print Coupons");
if (dialog->exec() != QDialog::Accepted)
return;
QPainter painter(&printer);
printScene.setSceneRect(0, 0, 920, 1400);
img.loadFromData(coupon.couponFile);
coupon.drawCouponPage(&printScene, img, ui->horizontalSlider->value());
printScene.render(&painter);
ui->statusBar->showMessage("Coupon page sent to printer.");
}
示例13: printButtonPushed
void barchartdialog::printButtonPushed()
{
QPrinter printer;
QPrintDialog *dialog = new QPrintDialog(&printer, this);
dialog->setWindowTitle(tr("Print Document"));
if (dialog->exec() != QDialog::Accepted)
return;
QPixmap pixmap = QPixmap::grabWidget(this, 0, 0, -1, -1);
QPainter painter;
painter.begin(&printer);
painter.drawImage(0, 0, pixmap.toImage());
painter.end();
}
示例14: documentPrint
void MainWindow::documentPrint(void)
{
Canvas *currCanvas = canvas();
QPrinter printer;
QPrintDialog *dialog = new QPrintDialog(&printer, this);
dialog->setWindowTitle(tr("Print Document"));
if (dialog->exec() == QDialog::Accepted)
{
QPainter painter(&printer);
painter.setRenderHint(QPainter::Antialiasing);
currCanvas->setRenderingForPrinting(true);
currCanvas->render(&painter, QRectF(),
currCanvas->pageRect());
currCanvas->setRenderingForPrinting(false);
}
}
示例15: printImage
void KStars::printImage( bool usePrintDialog, bool useChartColors ) {
//QPRINTER_FOR_NOW
// KPrinter printer( true, QPrinter::HighResolution );
QPrinter printer( QPrinter::HighResolution );
printer.setFullPage( false );
//Set up the printer (either with the Print Dialog,
//or using the default settings)
bool ok( false );
if ( usePrintDialog ) {
//QPRINTER_FOR_NOW
// ok = printer.setup( this, i18n("Print Sky") );
QPrintDialog *dialog = KdePrint::createPrintDialog(&printer, this);
dialog->setWindowTitle( i18n("Print Sky") );
if ( dialog->exec() == QDialog::Accepted )
ok = true;
delete dialog;
} else {
//QPRINTER_FOR_NOW
// ok = printer.autoConfigure();
ok = true;
}
if( ok ) {
QApplication::setOverrideCursor( Qt::WaitCursor );
//Save current ColorScheme file name and switch to Star Chart
//scheme (if requested)
QString schemeName = data()->colorScheme()->fileName();
if ( useChartColors ) {
loadColorScheme( "chart.colors" );
}
map()->setupProjector();
map()->exportSkyImage( &printer );
//Restore old color scheme if necessary
//(if printing was aborted, the ColorScheme is still restored)
if ( useChartColors ) {
loadColorScheme( schemeName );
map()->forceUpdate();
}
QApplication::restoreOverrideCursor();
}
}