本文整理汇总了C++中QPrintDialog::setOption方法的典型用法代码示例。如果您正苦于以下问题:C++ QPrintDialog::setOption方法的具体用法?C++ QPrintDialog::setOption怎么用?C++ QPrintDialog::setOption使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPrintDialog
的用法示例。
在下文中一共展示了QPrintDialog::setOption方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: print
void PrintTool::print()
{
const QString processTitle = i18nc( "@title:window", "Print Byte Array %1", mDocument->title() );
QPrinter printer;
// LayoutDialogPage* layoutPage = new LayoutDialogPage();
QList<QWidget*> customDialogPages;
// customDialogPages << layoutPage;
QPrintDialog *printDialog = new QPrintDialog( &printer, 0 );
// Disable PrintPageRange, this tells Qt we can't do client-side page selection,
// so it will try do server-side page selection if supported
printDialog->setOption(QPrintDialog::PrintPageRange, false);
// printDialog->setOptionTabs(customDialogPages);
printDialog->setWindowTitle( processTitle );
if( printDialog->exec() )
{
QString creator = QString::fromLatin1( "Print Plugin for Okteta " ); // no i18n(), keep space at end as separator
// creator += KDEUTILS_VERSION_STRING; // TODO: change to OKTETA_VERSION_STRING
printer.setCreator( creator );
FramesToPaperPrinter framesPrinter;
framesPrinter.setPaperRect( printer.paperRect() );
framesPrinter.setPageRect( printer.pageRect() );
printer.setFullPage( true );
PrintInfo info;
const QRect pageRect = framesPrinter.pageRect();
const int left = pageRect.left();
const int width = pageRect.width();
HeaderFooterFrameRenderer *headerFrameRenderer = new HeaderFooterFrameRenderer( &info );
headerFrameRenderer->setTexts( QStringLiteral("%d"),
QStringLiteral("%f"),
i18nc("in the header of the printed page, e.g. Page 2 of 20","Page %p of %P") );
headerFrameRenderer->setWidth( width );
headerFrameRenderer->setPos( pageRect.topLeft() );
HeaderFooterFrameRenderer *footerFrameRenderer = new HeaderFooterFrameRenderer( &info );
footerFrameRenderer->setTexts( i18nc("in the footer of the printed page, e.g. Printed by: Joe User",
"Printed by: %U"),
QString(),
QStringLiteral("%F") );
footerFrameRenderer->setWidth( width );
const int footerTop = pageRect.bottom() - footerFrameRenderer->height();
footerFrameRenderer->setPos( left, footerTop );
const int contentHeight = pageRect.height() - footerFrameRenderer->height() - headerFrameRenderer->height();
const int contentTop = pageRect.top() + headerFrameRenderer->height();
ByteArrayFrameRenderer *byteArrayFrameRenderer = new ByteArrayFrameRenderer;
byteArrayFrameRenderer->setPos( left, contentTop );
byteArrayFrameRenderer->setWidth( width );
byteArrayFrameRenderer->setHeight( contentHeight );
Okteta::AddressRange range = mByteArrayView->selection();
if( ! range.isValid() )
range.setByWidth( 0, mByteArrayModel->size() );
byteArrayFrameRenderer->setByteArrayModel( mByteArrayModel, range.start(), range.width() );
// TODO: use noOfBytesPerLine of view, scale resolution down if it does not fit the page
const int noOfBytesPerLine = mByteArrayView->noOfBytesPerLine();
// byteArrayFrameRenderer->setNoOfBytesPerLine( mByteArrayView->noOfBytesPerLine() );
const Okteta::Address startOffset = mByteArrayView->startOffset() + range.start();
const int line = startOffset / noOfBytesPerLine;
const Okteta::Address firstLineOffset = mByteArrayView->firstLineOffset() + line*noOfBytesPerLine;
byteArrayFrameRenderer->setFirstLineOffset( firstLineOffset );
byteArrayFrameRenderer->setStartOffset( startOffset );
byteArrayFrameRenderer->setCharCoding( mByteArrayView->charCodingName() );
byteArrayFrameRenderer->setBufferSpacing( mByteArrayView->byteSpacingWidth(),
mByteArrayView->noOfGroupedBytes(),
mByteArrayView->groupSpacingWidth() );
byteArrayFrameRenderer->setBinaryGapWidth( mByteArrayView->binaryGapWidth() );
byteArrayFrameRenderer->setValueCoding( (Okteta::ValueCoding)mByteArrayView->valueCoding() );
byteArrayFrameRenderer->setShowsNonprinting( mByteArrayView->showsNonprinting() );
byteArrayFrameRenderer->setSubstituteChar( mByteArrayView->substituteChar() );
byteArrayFrameRenderer->setUndefinedChar( mByteArrayView->undefinedChar() );
byteArrayFrameRenderer->showByteArrayColumns( mByteArrayView->visibleByteArrayCodings() );
// if( !confirmPrintPageNumber( byteArrayFrameRenderer->framesCount()) )
// return;
framesPrinter.addFrameRenderer( headerFrameRenderer );
framesPrinter.addFrameRenderer( byteArrayFrameRenderer );
framesPrinter.addFrameRenderer( footerFrameRenderer );
info.setNoOfPages( byteArrayFrameRenderer->framesCount() );
AbstractModelSynchronizer* synchronizer = mDocument->synchronizer();
if (synchronizer) {
info.setUrl( synchronizer->url() );
}
QApplication::setOverrideCursor( Qt::WaitCursor );
PrintJob *printJob = new PrintJob( &framesPrinter, 0, byteArrayFrameRenderer->framesCount()-1, &printer );
const bool success = printJob->exec();
//.........这里部分代码省略.........