本文整理汇总了C++中QPrinter::printerState方法的典型用法代码示例。如果您正苦于以下问题:C++ QPrinter::printerState方法的具体用法?C++ QPrinter::printerState怎么用?C++ QPrinter::printerState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPrinter
的用法示例。
在下文中一共展示了QPrinter::printerState方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: printerState
QPrinter::PrinterState QPrinterProto::printerState() const
{
QPrinter *item = qscriptvalue_cast<QPrinter*>(thisObject());
if (item)
return item->printerState();
return QPrinter::Idle;
}
示例2:
void GL_widget_2::export_to_vector(QString file_name) {
QPrinter printer;
printer.setOutputFileName(file_name);
printer.setResolution(72);
printer.setPageSize(QPrinter::A0);
// printer.setOrientation(QPrinter::Landscape); //ps would be not correct
printer.setFullPage(true);
printer.setColorMode(QPrinter::Color);
QPainter painter;
set_renderer_type(GL_widget_2::QT_PAINTER);
set_painter(&painter);
painter.begin(&printer);
paint_to_painter();
painter.end();
set_painter(0);
set_renderer_type(GL_widget_2::OPEN_GL);
if (printer.printerState() < 2) // idle or active
std::cout << "Image written to " << file_name.toStdString() << std::endl;
else
std::cout << "Could not write image to " << file_name.toStdString() << std::endl;
}
示例3: doPrintFiles
int FilePrinter::doPrintFiles( QPrinter &printer, QStringList fileList, FileDeletePolicy fileDeletePolicy,
PageSelectPolicy pageSelectPolicy, const QString &pageRange,
QPrinter::Orientation documentOrientation )
{
if ( fileList.size() < 1 ) {
return -8;
}
for (QStringList::ConstIterator it = fileList.constBegin(); it != fileList.constEnd(); ++it) {
if (!QFile::exists(*it)) {
return -7;
}
}
if ( printer.printerState() == QPrinter::Aborted || printer.printerState() == QPrinter::Error ) {
return -6;
}
QString exe;
QStringList argList;
int ret;
// Print to File if a filename set, assumes there must be only 1 file
if ( !printer.outputFileName().isEmpty() ) {
if ( QFile::exists( printer.outputFileName() ) ) {
QFile::remove( printer.outputFileName() );
}
QFileInfo inputFileInfo = QFileInfo( fileList[0] );
QFileInfo outputFileInfo = QFileInfo( printer.outputFileName() );
bool doDeleteFile = (fileDeletePolicy == FilePrinter::SystemDeletesFiles);
if ( inputFileInfo.suffix() == outputFileInfo.suffix() ) {
if ( doDeleteFile ) {
bool res = QFile::rename( fileList[0], printer.outputFileName() );
if ( res ) {
doDeleteFile = false;
ret = 0;
} else {
ret = -5;
}
} else {
bool res = QFile::copy( fileList[0], printer.outputFileName() );
if ( res ) {
ret = 0;
} else {
ret = -5;
}
}
} else if ( inputFileInfo.suffix() == "ps" && printer.outputFormat() == QPrinter::PdfFormat && ps2pdfAvailable() ) {
exe = "ps2pdf";
argList << fileList[0] << printer.outputFileName();
kDebug(OkularDebug) << "Executing" << exe << "with arguments" << argList;
ret = KProcess::execute( exe, argList );
} else if ( inputFileInfo.suffix() == "pdf" && printer.outputFormat() == QPrinter::PostScriptFormat && pdf2psAvailable() ) {
exe = "pdf2ps";
argList << fileList[0] << printer.outputFileName();
kDebug(OkularDebug) << "Executing" << exe << "with arguments" << argList;
ret = KProcess::execute( exe, argList );
} else {
ret = -5;
}
if ( doDeleteFile ) {
QFile::remove( fileList[0] );
}
} else { // Print to a printer via lpr command
//Decide what executable to use to print with, need the CUPS version of lpr if available
//Some distros name the CUPS version of lpr as lpr-cups or lpr.cups so try those first
//before default to lpr, or failing that to lp
if ( !KStandardDirs::findExe("lpr-cups").isEmpty() ) {
exe = "lpr-cups";
} else if ( !KStandardDirs::findExe("lpr.cups").isEmpty() ) {
exe = "lpr.cups";
} else if ( !KStandardDirs::findExe("lpr").isEmpty() ) {
exe = "lpr";
} else if ( !KStandardDirs::findExe("lp").isEmpty() ) {
exe = "lp";
} else {
return -9;
}
bool useCupsOptions = cupsAvailable();
argList = printArguments( printer, fileDeletePolicy, pageSelectPolicy,
useCupsOptions, pageRange, exe, documentOrientation ) << fileList;
kDebug(OkularDebug) << "Executing" << exe << "with arguments" << argList;
ret = KProcess::execute( exe, argList );
}
return ret;
}
示例4: doPrintFile
void FilePrinter::doPrintFile( QPrinter &printer, const QString &file, FileDeletePolicy fileDeletePolicy,
PageSelectPolicy pageSelectPolicy, const QString &pageRange )
{
if (!QFile::exists(file)) {
return;
}
bool doDeleteFile = (fileDeletePolicy == FilePrinter::SystemDeletesFiles);
if ( printer.printerState() == QPrinter::Aborted || printer.printerState() == QPrinter::Error ) {
if ( doDeleteFile ) {
QFile::remove( file );
}
return;
}
// Print to a printer via lpr command
//Decide what executable to use to print with, need the CUPS version of lpr if available
//Some distros name the CUPS version of lpr as lpr-cups or lpr.cups so try those first
//before default to lpr, or failing that to lp
QString exe;
if ( !QStandardPaths::findExecutable(QStringLiteral("lpr-cups")).isEmpty() ) {
exe = QStringLiteral("lpr-cups");
} else if ( !QStandardPaths::findExecutable(QStringLiteral("lpr.cups")).isEmpty() ) {
exe = QStringLiteral("lpr.cups");
} else if ( !QStandardPaths::findExecutable(QStringLiteral("lpr")).isEmpty() ) {
exe = QStringLiteral("lpr");
} else if ( !QStandardPaths::findExecutable(QStringLiteral("lp")).isEmpty() ) {
exe = QStringLiteral("lp");
} else {
if ( doDeleteFile ) {
QFile::remove( file );
}
return;
}
bool useCupsOptions = cupsAvailable();
QStringList argList = printArguments( printer, fileDeletePolicy, pageSelectPolicy,
useCupsOptions, pageRange, exe ) << file;
QProcess *process = new QProcess();
QObject::connect(process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error), [=](QProcess::ProcessError) {
if ( doDeleteFile ) {
QFile::remove( file );
}
process->deleteLater();
});
QObject::connect(process, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), [=](int exitCode, QProcess::ExitStatus exitStatus) {
if ( doDeleteFile && (exitStatus != QProcess::NormalExit || exitCode != 0) ) {
// lpr failed, so delete the temporary file in case it still exists.
// In case of success, we let lpr delete it, it knows best when it is safe to do so.
// (lpr queues jobs asynchronously.)
QFile::remove( file );
}
process->deleteLater();
});
process->start( exe, argList );
}
示例5: printerState
int Printer::printerState(lua_State * L) // const : PrinterState
{
QPrinter* lhs = ValueBinding<MyQPrinter>::check( L, 1 );
Util::push( L, lhs->printerState() );
return 1;
}