📄 qprinter.cpp
字号:
#endif/*! \fn QString QPrinter::printerSelectionOption() const Returns the printer options selection string. This is useful only if the print command has been explicitly set. The default value (an empty string) implies that the printer should be selected in a system-dependent manner. Any other value implies that the given value should be used. \warning This function is not available on Windows. \sa setPrinterSelectionOption()*//*! \fn void QPrinter::setPrinterSelectionOption(const QString &option) Sets the printer to use \a option to select the printer. \a option is null by default (which implies that Qt should be smart enough to guess correctly), but it can be set to other values to use a specific printer selection option. If the printer selection option is changed while the printer is active, the current print job may or may not be affected. \warning This function is not available on Windows. \sa printerSelectionOption()*/#ifndef Q_WS_WINQString QPrinter::printerSelectionOption() const{ Q_D(const QPrinter); return d->printEngine->property(QPrintEngine::PPK_SelectionOption).toString();}void QPrinter::setPrinterSelectionOption(const QString &option){ Q_D(QPrinter); d->printEngine->setProperty(QPrintEngine::PPK_SelectionOption, option);}#endif/*! \since 4.1 \fn int QPrinter::fromPage() const Returns the from-page setting. The default value is 0. If fromPage() and toPage() both return 0 this signifies 'print the whole document'. \sa setFromTo(), toPage()*/int QPrinter::fromPage() const{ Q_D(const QPrinter); return d->fromPage;}/*! \since 4.1 Returns the to-page setting. The default value is 0. If fromPage() and toPage() both return 0 this signifies 'print the whole document'. The programmer is responsible for reading this setting and printing accordingly. \sa setFromTo(), fromPage()*/int QPrinter::toPage() const{ Q_D(const QPrinter); return d->toPage;}/*! \since 4.1 Sets the from-page and to-page settings to \a from and \a to respectively. The from-page and to-page settings specify what pages to print. If from and to both return 0 this signifies 'print the whole document'. This function is useful mostly to set a default value that the user can override in the print dialog when you call setup(). \sa fromPage(), toPage()*/void QPrinter::setFromTo(int from, int to){ Q_D(QPrinter); Q_ASSERT_X(from <= to, "QPrinter::setFromTo", "'from' must be less than or equal to 'to'"); d->fromPage = from; d->toPage = to; if (d->minPage == 0 && d->maxPage == 0) { d->minPage = 1; d->maxPage = to; d->options |= QAbstractPrintDialog::PrintPageRange; }}/*! \since 4.1 Sets the print range option in to be \a range.*/void QPrinter::setPrintRange( PrintRange range ){ Q_D(QPrinter); d->printRange = QAbstractPrintDialog::PrintRange(range);}/*! \since 4.1 Returns the page range of the QPrinter. After the print setup dialog has been opened, this function returns the value selected by the user. \sa setPrintRange()*/QPrinter::PrintRange QPrinter::printRange() const{ Q_D(const QPrinter); return PrintRange(d->printRange);}#if defined(QT3_SUPPORT)void QPrinter::setOutputToFile(bool f){ if (f) { if (outputFileName().isEmpty()) setOutputFileName(QLatin1String("untitled_printer_document")); } else { setOutputFileName(QString()); }}bool qt_compat_QPrinter_printSetup(QPrinter *printer, QPrinterPrivate *pd, QWidget *parent){ Q_UNUSED(pd); QPrintDialog dlg(printer, parent); return dlg.exec() != 0;}#ifdef Q_WS_MACbool qt_compat_QPrinter_pageSetup(QPrinter *p, QWidget *parent){ QPageSetupDialog psd(p, parent); return psd.exec() != 0;}/*! Executes a page setup dialog so that the user can configure the type of page used for printing. Returns true if the contents of the dialog are accepted; returns false if the dialog is canceled.*/bool QPrinter::pageSetup(QWidget *parent){ return qt_compat_QPrinter_pageSetup(this, parent);}/*! Executes a print setup dialog so that the user can configure the printing process. Returns true if the contents of the dialog are accepted; returns false if the dialog is canceled.*/bool QPrinter::printSetup(QWidget *parent){ Q_D(QPrinter); return qt_compat_QPrinter_printSetup(this, d, parent);}#endif // Q_WS_MAC/*! Use QPrintDialog instead. \oldcode if (printer->setup(parent)) ... \newcode QPrintDialog dialog(printer, parent); if (dialog.exec()) ... \endcode*/bool QPrinter::setup(QWidget *parent){ Q_D(QPrinter); return qt_compat_QPrinter_printSetup(this, d, parent)#ifdef Q_WS_MAC && qt_compat_QPrinter_pageSetup(this, parent);#endif ;}/*! Use QPrintDialog::minPage() instead.*/int QPrinter::minPage() const{ Q_D(const QPrinter); return d->minPage;}/*! Use QPrintDialog::maxPage() instead.*/int QPrinter::maxPage() const{ Q_D(const QPrinter); return d->maxPage;}/*! Use QPrintDialog::setMinMax() instead.*/void QPrinter::setMinMax( int minPage, int maxPage ){ Q_D(QPrinter); Q_ASSERT_X(minPage <= maxPage, "QPrinter::setMinMax", "'min' must be less than or equal to 'max'"); d->minPage = minPage; d->maxPage = maxPage; d->options |= QPrintDialog::PrintPageRange;}/*! Returns true if the printer is set up to collate copies of printed documents; otherwise returns false. Use QPrintDialog::isOptionEnabled(QPrintDialog::PrintCollateCopies) instead. \sa collateCopies()*/bool QPrinter::collateCopiesEnabled() const{ Q_D(const QPrinter); return (d->options & QPrintDialog::PrintCollateCopies);}/*! Use QPrintDialog::addEnabledOption(QPrintDialog::PrintCollateCopies) or QPrintDialog::setEnabledOptions(QPrintDialog::enabledOptions() & ~QPrintDialog::PrintCollateCopies) instead, depending on \a enable.*/void QPrinter::setCollateCopiesEnabled(bool enable){ Q_D(QPrinter); if (enable) d->options |= QPrintDialog::PrintCollateCopies; else d->options &= ~QPrintDialog::PrintCollateCopies;}/*! Use QPrintDialog instead.*/void QPrinter::setOptionEnabled( PrinterOption option, bool enable ){ Q_D(QPrinter); if (enable) d->options |= QPrintDialog::PrintDialogOption(1 << option); else d->options &= ~QPrintDialog::PrintDialogOption(1 << option);}/*! Use QPrintDialog instead.*/bool QPrinter::isOptionEnabled( PrinterOption option ) const{ Q_D(const QPrinter); return (d->options & QPrintDialog::PrintDialogOption(option));}#endif // QT3_SUPPORT/*! \class QPrintEngine \ingroup multimedia \brief The QPrintEngine class defines an interface for how QPrinter interacts with a given printing subsystem. The common case when creating your own print engine is to derive from both QPaintEngine and QPrintEngine. Various properties of a print engine are given with property() and set with setProperty(). \sa QPaintEngine*//*! \enum QPrintEngine::PrintEnginePropertyKey This enum is used to communicate properties between the print engine and QPrinter. A property may or may not be supported by a given print engine. \value PPK_CollateCopies A boolean value indicating whether the printout should be collated or not. \value PPK_ColorMode Refers to QPrinter::ColorMode, either color or monochrome. \value PPK_Creator A string describing the document's creator. \value PPK_Duplex A boolean value indicating whether both sides of the printer paper should be used for the printout. \value PPK_DocumentName A string describing the document name in the spooler. \value PPK_FontEmbedding A boolean value indicating whether data for the document's fonts should be embedded in the data sent to the printer. \value PPK_FullPage A boolean describing if the printer should be full page or not. \value PPK_NumberOfCopies An integer specifying the number of copies \value PPK_Orientation Specifies a QPrinter::Orientation value. \value PPK_OutputFileName The output file name as a string. An empty file name indicates that the printer should not print to a file. \value PPK_PageOrder Specifies a QPrinter::PageOrder value. \value PPK_PageRect A QRect specifying the page rectangle \value PPK_PageSize Specifies a QPrinter::PageSize value. \value PPK_PaperRect A QRect specifying the paper rectangle. \value PPK_PaperSource Specifies a QPrinter::PaperSource value. \value PPK_PaperSources Specifies more than one QPrinter::PaperSource value. \value PPK_PrinterName A string specifying the name of the printer. \value PPK_PrinterProgram A string specifying the name of the printer program used for printing, \value PPK_Resolution An integer describing the dots per inch for this printer. \value PPK_SelectionOption \value PPK_SupportedResolutions A list of integer QVariants describing the set of supported resolutions that the printer has. \value PPK_SuppressSystemPrintStatus Suppress the built-in dialog for showing printing progress. As of 4.1 this only has effect on Mac OS X where, by default, a status dialog is shown. \value PPK_WindowsPageSize An integer specifying a DM_PAPER entry on Windows. \value PPK_CustomBase Basis for extension.*//*! \fn QPrintEngine::~QPrintEngine() Destroys the print engine.*//*! \fn void QPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &value) Sets the print engine's property specified by \a key to the given \a value. \sa property()*//*! \fn void QPrintEngine::property(PrintEnginePropertyKey key) const Returns the print engine's property specified by \a key. \sa setProperty()*//*! \fn bool QPrintEngine::newPage() Instructs the print engine to start a new page. Returns true if the printer was able to create the new page; otherwise returns false.*//*! \fn bool QPrintEngine::abort() Instructs the print engine to abort the printing process. Returns true if successful; otherwise returns false.*//*! \fn int QPrintEngine::metric(QPaintDevice::PaintDeviceMetric id) const Returns the metric for the given \a id.*//*! \fn QPrinter::PrinterState QPrintEngine::printerState() const Returns the current state of the printer being used by the print engine.*//*! \fn HDC QPrintEngine::getPrinterDC() const \internal*//*! \fn void QPrintEngine::releasePrinterDC(HDC) const \internal*/#endif // QT_NO_PRINTER
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -