本文整理汇总了C++中QPrinter::setPrintRange方法的典型用法代码示例。如果您正苦于以下问题:C++ QPrinter::setPrintRange方法的具体用法?C++ QPrinter::setPrintRange怎么用?C++ QPrinter::setPrintRange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPrinter
的用法示例。
在下文中一共展示了QPrinter::setPrintRange方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setPrintRange
int Printer::setPrintRange(lua_State * L) // ( PrintRange range )
{
QPrinter* lhs = ValueBinding<MyQPrinter>::check( L, 1 );
QPrinter::PrintRange f=(QPrinter::PrintRange)Util::toInt( L, 2 );
lhs->setPrintRange( f );
return 0;
}
示例2: print
bool KatePrinter::print (KateDocument *doc)
{
QPrinter printer;
readSettings(printer);
// docname is now always there, including the right Untitled name
printer.setDocName(doc->documentName());
KatePrintTextSettings *kpts = new KatePrintTextSettings;
KatePrintHeaderFooter *kphf = new KatePrintHeaderFooter;
KatePrintLayout *kpl = new KatePrintLayout;
QList<QWidget*> tabs;
tabs << kpts;
tabs << kphf;
tabs << kpl;
QWidget *parentWidget=doc->widget();
if ( !parentWidget )
parentWidget=QApplication::activeWindow();
QScopedPointer<QPrintDialog> printDialog(KdePrint::createPrintDialog(&printer, KdePrint::SystemSelectsPages, tabs, parentWidget));
if ( doc->activeView()->selection() ) {
printer.setPrintRange(QPrinter::Selection);
printDialog->setOption(QAbstractPrintDialog::PrintSelection, true);
}
if ( printDialog->exec() )
{
writeSettings(printer);
KateRenderer renderer(doc, doc->activeKateView());
renderer.config()->setSchema (kpl->colorScheme());
renderer.setPrinterFriendly(true);
QPainter paint( &printer );
/*
* We work in tree cycles:
* 1) initialize variables and retrieve print settings
* 2) prepare data according to those settings
* 3) draw to the printer
*/
uint pdmWidth = printer.width();
uint pdmHeight = printer.height();
int y = 0;
uint xstart = 0; // beginning point for painting lines
uint lineCount = 0;
uint maxWidth = pdmWidth;
int headerWidth = pdmWidth;
int startCol = 0;
int endCol = 0;
bool pageStarted = true;
int remainder = 0; // remaining sublines from a wrapped line (for the top of a new page)
// Text Settings Page
bool selectionOnly = (printDialog->printRange() == QAbstractPrintDialog::Selection);
bool useGuide = kpts->printGuide();
bool printLineNumbers = kpts->printLineNumbers();
uint lineNumberWidth( 0 );
// Header/Footer Page
QFont headerFont(kphf->font()); // used for header/footer
bool useHeader = kphf->useHeader();
QColor headerBgColor(kphf->headerBackground());
QColor headerFgColor(kphf->headerForeground());
uint headerHeight( 0 ); // further init only if needed
QStringList headerTagList; // do
bool headerDrawBg = false; // do
bool useFooter = kphf->useFooter();
QColor footerBgColor(kphf->footerBackground());
QColor footerFgColor(kphf->footerForeground());
uint footerHeight( 0 ); // further init only if needed
QStringList footerTagList; // do
bool footerDrawBg = false; // do
// Layout Page
renderer.config()->setSchema( kpl->colorScheme() );
bool useBackground = kpl->useBackground();
bool useBox = kpl->useBox();
int boxWidth(kpl->boxWidth());
QColor boxColor(kpl->boxColor());
int innerMargin = useBox ? kpl->boxMargin() : 6;
// Post initialization
int maxHeight = (useBox ? pdmHeight-innerMargin : pdmHeight);
uint currentPage( 1 );
uint lastline = doc->lastLine(); // necessary to print selection only
uint firstline( 0 );
const int fontHeight = renderer.fontHeight();
KTextEditor::Range selectionRange;
/*
* Now on for preparations...
* during preparations, variable names starting with a "_" means
* those variables are local to the enclosing block.
//.........这里部分代码省略.........
示例3: setPrintRange
void QPrinterProto::setPrintRange(QPrinter::PrintRange range)
{
QPrinter *item = qscriptvalue_cast<QPrinter*>(thisObject());
if (item)
item->setPrintRange(range);
}