⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qprinter.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 4 页
字号:
    d->use_default_engine = false;}/*!    Destroys the printer object and frees any allocated resources. If    the printer is destroyed while a print job is in progress this may    or may not affect the print job.*/QPrinter::~QPrinter(){    Q_D(QPrinter);    if (d->use_default_engine)        delete d->printEngine;    delete d;}/*!    \enum QPrinter::OutputFormat    The OutputFormat enum is used to describe the format QPrinter should    use for printing.    \value NativeFormat QPrinter will print output using a method defined    by the platform it is running on. This mode is the default when printing    directly to a printer.    \value PdfFormat QPrinter will generate its output as a searchable PDF file.    This mode is the default when printing to a file.    \value PostScriptFormat QPrinter will generate its output as in the PostScript format.    (This feature was introduced in Qt 4.2.)    \sa outputFormat(), setOutputFormat(), setOutputFileName()*//*!    \since 4.1    Sets the output format for this printer to \a format.*/void QPrinter::setOutputFormat(OutputFormat format){#ifndef QT_NO_PDF    Q_D(QPrinter);    if (d->outputFormat == format)        return;    d->outputFormat = format;    QPrintEngine *oldPrintEngine = d->printEngine;    const bool def_engine = d->use_default_engine;    d->printEngine = 0;    d->createDefaultEngines();    if (oldPrintEngine) {        for (int i = 0; i < QPrintEngine::PPK_CustomBase; ++i) {            QPrintEngine::PrintEnginePropertyKey key = (QPrintEngine::PrintEnginePropertyKey)i;            QVariant prop = oldPrintEngine->property(key);            if (prop.isValid())                d->printEngine->setProperty(key, prop);        }    }    if (def_engine)        delete oldPrintEngine;#else    Q_UNUSED(format);#endif}/*!    \since 4.1    Returns the output format for this printer.*/QPrinter::OutputFormat QPrinter::outputFormat() const{    Q_D(const QPrinter);    return d->outputFormat;}/*! \reimp */int QPrinter::devType() const{    return QInternal::Printer;}/*!    Returns the printer name. This value is initially set to the name    of the default printer.    \sa setPrinterName()*/QString QPrinter::printerName() const{    Q_D(const QPrinter);    return d->printEngine->property(QPrintEngine::PPK_PrinterName).toString();}/*!    Sets the printer name to \a name.    \sa printerName()*/void QPrinter::setPrinterName(const QString &name){    Q_D(QPrinter);    ABORT_IF_ACTIVE("QPrinter::setPrinterName");#if defined(Q_OS_UNIX) && !defined(QT_NO_CUPS)    if(d->use_default_engine        && d->outputFormat == QPrinter::NativeFormat) {        if (QCUPSSupport::cupsVersion() >= 10200            && QCUPSSupport::printerHasPPD(name.toLocal8Bit().constData()))            setOutputFormat(QPrinter::PdfFormat);        else            setOutputFormat(QPrinter::PostScriptFormat);        d->outputFormat = QPrinter::NativeFormat;    }#endif    d->printEngine->setProperty(QPrintEngine::PPK_PrinterName, name);}/*!  \fn bool QPrinter::outputToFile() const  Returns true if the output should be written to a file, or false  if the output should be sent directly to the printer. The default  setting is false.  \sa setOutputToFile(), setOutputFileName()*//*!  \fn void QPrinter::setOutputToFile(bool enable)  Specifies whether the output should be written to a file or sent  directly to the printer.  Will output to a file if \a enable is true, or will output  directly to the printer if \a enable is false.  \sa outputToFile(), setOutputFileName()*//*!  \fn QString QPrinter::outputFileName() const  Returns the name of the output file. By default, this is an empty string  (indicating that the printer shouldn't print to file).*/QString QPrinter::outputFileName() const{    Q_D(const QPrinter);    return d->printEngine->property(QPrintEngine::PPK_OutputFileName).toString();}/*!  Sets the name of the output file to \a fileName.  Setting a null or empty name (0 or "") disables printing to a file. Setting a  non-empty name enables printing to a file.  This can change the value of outputFormat().  If the file name has the suffix  ".ps" then PostScript is automatically selected as output format. If the file  name has the ".pdf" suffix PDF is generated.  QPrinter will use Qt's  cross-platform PostScript or PDF print engines respectively. If you can  produce this format natively, for example Mac OS X can generate PDF's from  its print engine, set the output format back to NativeFormat.  \sa outputFileName() setOutputToFile() setOutputFormat()*/void QPrinter::setOutputFileName(const QString &fileName){    Q_D(QPrinter);    ABORT_IF_ACTIVE("QPrinter::setOutputFileName");    QFileInfo fi(fileName);    if (!fi.suffix().compare(QLatin1String("ps"), Qt::CaseInsensitive))        setOutputFormat(QPrinter::PostScriptFormat);    else if (!fi.suffix().compare(QLatin1String("pdf"), Qt::CaseInsensitive))        setOutputFormat(QPrinter::PdfFormat);    else if (fileName.isEmpty())        setOutputFormat(QPrinter::NativeFormat);    d->printEngine->setProperty(QPrintEngine::PPK_OutputFileName, fileName);}/*!  Returns the name of the program that sends the print output to the  printer.  The default is to return an empty string; meaning that QPrinter will try to  be smart in a system-dependent way. On X11 only, you can set it to something  different to use a specific print program. On the other platforms, this  returns an empty string.  \sa setPrintProgram(), setPrinterSelectionOption()*/QString QPrinter::printProgram() const{    Q_D(const QPrinter);    return d->printEngine->property(QPrintEngine::PPK_PrinterProgram).toString();}/*!  Sets the name of the program that should do the print job to \a  printProg.  On X11, this function sets the program to call with the PostScript  output. On other platforms, it has no effect.  \sa printProgram()*/void QPrinter::setPrintProgram(const QString &printProg){    Q_D(QPrinter);    ABORT_IF_ACTIVE("QPrinter::setPrintProgram");    d->printEngine->setProperty(QPrintEngine::PPK_PrinterProgram, printProg);}/*!  Returns the document name.  \sa setDocName()*/QString QPrinter::docName() const{    Q_D(const QPrinter);    return d->printEngine->property(QPrintEngine::PPK_DocumentName).toString();}/*!  Sets the document name to \a name.*/void QPrinter::setDocName(const QString &name){    Q_D(QPrinter);    ABORT_IF_ACTIVE("QPrinter::setDocName");    d->printEngine->setProperty(QPrintEngine::PPK_DocumentName, name);}/*!  Returns the name of the application that created the document.  \sa setCreator()*/QString QPrinter::creator() const{    Q_D(const QPrinter);    return d->printEngine->property(QPrintEngine::PPK_Creator).toString();}/*!  Sets the name of the application that created the document to \a  creator.  This function is only applicable to the X11 version of Qt. If no  creator name is specified, the creator will be set to "Qt"  followed by some version number.  \sa creator()*/void QPrinter::setCreator(const QString &creator){    Q_D(QPrinter);    ABORT_IF_ACTIVE("QPrinter::setCreator");    d->printEngine->setProperty(QPrintEngine::PPK_Creator, creator);}/*!  Returns the orientation setting. This is driver-dependent, but is usually  QPrinter::Portrait.  \sa setOrientation()*/QPrinter::Orientation QPrinter::orientation() const{    Q_D(const QPrinter);    return QPrinter::Orientation(d->printEngine->property(QPrintEngine::PPK_Orientation).toInt());}/*!  Sets the print orientation to \a orientation.  The orientation can be either QPrinter::Portrait or  QPrinter::Landscape.  The printer driver reads this setting and prints using the  specified orientation.  On Windows, this option can be changed while printing and will  take effect from the next call to newPage().  On Mac OS X, changing the orientation during a print job has no effect.  \sa orientation()*/void QPrinter::setOrientation(Orientation orientation){    Q_D(QPrinter);    d->printEngine->setProperty(QPrintEngine::PPK_Orientation, orientation);}/*!  Returns the printer page size. The default value is driver-dependent.  \sa setPageSize() pageRect() paperRect()*/QPrinter::PageSize QPrinter::pageSize() const{    Q_D(const QPrinter);    return QPrinter::PageSize(d->printEngine->property(QPrintEngine::PPK_PageSize).toInt());}/*!  Sets the printer page size to \a newPageSize if that size is  supported. The result if undefined if \a newPageSize is not  supported.  The default page size is driver-dependent.  This function is useful mostly for setting a default value that  the user can override in the print dialog.  \sa pageSize() PageSize setFullPage() setResolution() pageRect() paperRect()*/void QPrinter::setPageSize(PageSize newPageSize){    Q_D(QPrinter);    ABORT_IF_ACTIVE("QPrinter::setPageSize");    if (newPageSize > NPageSize) {        qWarning("QPrinter::SetPageSize: Illegal page size %d", newPageSize);        return;    }    d->printEngine->setProperty(QPrintEngine::PPK_PageSize, newPageSize);}/*!    Sets the page order to \a pageOrder.    The page order can be QPrinter::FirstPageFirst or    QPrinter::LastPageFirst. The application is responsible for    reading the page order and printing accordingly.    This function is mostly useful for setting a default value that    the user can override in the print dialog.*/void QPrinter::setPageOrder(PageOrder pageOrder){    Q_D(QPrinter);    ABORT_IF_ACTIVE("QPrinter::setPageOrder");    d->printEngine->setProperty(QPrintEngine::PPK_PageOrder, pageOrder);}/*!  Returns the current page order.  The default page order is \c FirstPageFirst.*/QPrinter::PageOrder QPrinter::pageOrder() const{    Q_D(const QPrinter);    return QPrinter::PageOrder(d->printEngine->property(QPrintEngine::PPK_PageOrder).toInt());}/*!  Sets the printer's color mode to \a newColorMode, which can be  either \c Color or \c GrayScale.  \sa colorMode()*/void QPrinter::setColorMode(ColorMode newColorMode){    Q_D(QPrinter);    ABORT_IF_ACTIVE("QPrinter::setColorMode");    d->printEngine->setProperty(QPrintEngine::PPK_ColorMode, newColorMode);}/*!  Returns the current color mode.  \sa setColorMode()*/QPrinter::ColorMode QPrinter::colorMode() const{    Q_D(const QPrinter);    return QPrinter::ColorMode(d->printEngine->property(QPrintEngine::PPK_ColorMode).toInt());}/*!  Returns the number of copies to be printed. The default value is 1.  On Windows, Mac OS X and X11 systems that support CUPS, this will always  return 1 as these operating systems can internally handle the number  of copies.  On X11, this value will return the number of times the application is  required to print in order to match the number specified in the printer setup  dialog. This has been done since some printer drivers are not capable of  buffering up the copies and in those cases the application must make an  explicit call to the print code for each copy.  \sa setNumCopies()*/int QPrinter::numCopies() const{    Q_D(const QPrinter);   return d->printEngine->property(QPrintEngine::PPK_NumberOfCopies).toInt();}/*!  Sets the number of copies to be printed to \a numCopies.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -