本文整理汇总了C++中QPrintDialog::setOptions方法的典型用法代码示例。如果您正苦于以下问题:C++ QPrintDialog::setOptions方法的具体用法?C++ QPrintDialog::setOptions怎么用?C++ QPrintDialog::setOptions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPrintDialog
的用法示例。
在下文中一共展示了QPrintDialog::setOptions方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: print
void Viewer::print() {
QPrinter printer(QPrinter::PrinterResolution);
QPrintDialog *printDialog = new QPrintDialog(&printer, this);
printDialog->setWindowTitle(QString::fromUtf8("katarakt/print %1").arg(get_res()->get_file()));
printDialog->setOptions(QAbstractPrintDialog::PrintPageRange | QAbstractPrintDialog::PrintCurrentPage);
int fromPage = 1, toPage = get_res()->get_page_count();
printDialog->setMinMax(fromPage, toPage);
printDialog->setFromTo(fromPage, toPage);
if (printDialog->exec() != QDialog::Accepted) {
delete printDialog;
return;
}
if (printer.printRange() == QPrinter::PageRange) {
fromPage = printer.fromPage();
toPage = printer.toPage();
} else if (printer.printRange() == QPrinter::CurrentPage) {
fromPage = toPage = canvas->get_layout()->get_page() + 1; // 0-indexed
}
QStringList list;
list << QString("-d") << QString("%1").arg(printer.printerName());
list << QString("-n") << QString("%1").arg(printer.copyCount());
list << QString("-P") << QString("%1-%2").arg(fromPage).arg(toPage);
if (printer.duplex() == QPrinter::DuplexLongSide) {
list << QString("-o") << QString("sides=two-sided-long-edge");
} else if (printer.duplex() == QPrinter::DuplexShortSide) {
list << QString("-o") << QString("sides=two-sided-short-edge");
}
// FIXME: how to set color / grayscale with lp? Or: how to disable it in print dialog?
list << QString("--");
list << QString("%1").arg(get_res()->get_file());
QProcess::execute("lp", list);
delete printDialog;
}