本文整理汇总了C++中QPicture::play方法的典型用法代码示例。如果您正苦于以下问题:C++ QPicture::play方法的具体用法?C++ QPicture::play怎么用?C++ QPicture::play使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPicture
的用法示例。
在下文中一共展示了QPicture::play方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawHeaderObjects
/** Draws the section base objects to the specified painter & x/y offsets */
void MReportSection::drawHeaderObjects( FLStylePainter *p, MPageCollection *pages, MReportSection * header ) {
MCalcObject * calcfield;
// Set the offsets
int xcalc = header->getLastXOffset();
int ycalc = header->getLastYOffset();
QPicture * currentPage = ( QPicture * ) p->painter()->device();
QPicture * lastPage = header->onPage();
QPicture * currentPageCopy = 0;
QPicture * lastPageCopy = 0;
if ( currentPage != lastPage ) {
p->painter()->end();
currentPageCopy = new QPicture( *currentPage );
lastPageCopy = new QPicture( *lastPage );
p->painter()->begin( lastPage );
lastPageCopy->play( p->painter() );
}
QObject::setName( QString( "_##H%1-%2" ).arg( strIdSec_ ).arg( level ) );
p->beginSection( xcalc, ycalc, width, height, this );
uint countObj = 0;
// Draw the calculated field collection
for ( calcfield = calculatedFields.first(); calcfield != 0;
calcfield = calculatedFields.next() ) {
if ( calcfield->getDrawAtHeader() ) {
calcfield->QObject::setName( QString( "_##H%1-Calc.%2-%3" ).arg( idSec_ ).arg( calcfield->fieldName ).arg( countObj++ ) );
p->beginMark( calcfield->getX(), calcfield->getY(), calcfield );
calcfield->draw( p );
p->endMark();
}
}
p->endSection();
if ( currentPage != lastPage ) {
p->painter()->end();
p->painter()->begin( currentPage );
currentPageCopy->play( p->painter() );
delete lastPageCopy;
delete currentPageCopy;
}
}
示例2: dumpPartPictures
void dumpPartPictures(const QHash<QString, QPicture> &partPictures) {
foreach (const QString &partKey, partPictures.keys()) {
QPicture partPicture = partPictures.value(partKey);
qDebug() << partKey << partPicture.boundingRect();
QImage image(partPicture.boundingRect().size(), QImage::Format_ARGB32);
image.fill(Qt::transparent);
QPainter p(&image);
partPicture.play(&p);
image.save(partKey + QString::fromLatin1(".png"));
}
}
示例3: serialization
void tst_QPicture::serialization()
{
QDataStream stream;
const int thisVersion = stream.version();
for (int version = QDataStream::Qt_1_0; version <= thisVersion; ++version) {
const QDataStream::Version versionEnum = static_cast<QDataStream::Version>(version);
{
// streaming of null pictures
ensureSerializesCorrectly(QPicture(), versionEnum);
}
{
// picture with a simple line, checking bitwise equality
QPicture picture;
QPainter painter(&picture);
painter.drawLine(10, 20, 30, 40);
ensureSerializesCorrectly(picture, versionEnum);
}
}
{
// Test features that were added after Qt 4.5, as that was hard-coded as the major
// version for a while, which was incorrect. In this case, we'll test font hints.
QPicture picture;
QPainter painter;
QFont font;
font.setStyleName("Blah");
font.setHintingPreference(QFont::PreferFullHinting);
painter.begin(&picture);
painter.setFont(font);
painter.drawText(20, 20, "Hello");
painter.end();
Picture customPicture;
painter.begin(&customPicture);
picture.play(&painter);
const QFont actualFont = ((PaintEngine*)customPicture.paintEngine())->font();
painter.end();
QCOMPARE(actualFont.styleName(), QStringLiteral("Blah"));
QCOMPARE(actualFont.hintingPreference(), QFont::PreferFullHinting);
}
}
示例4: printPosReport
bool MReportViewer::printPosReport()
{
if (report == 0)
return false;
posprinter = new FLPosPrinter();
posprinter->setPaperWidth((FLPosPrinter::PaperWidth) report->pageSize());
posprinter->setPrinterName(printerName_);
QPicture *page;
QPainter painter;
bool printRev = false;
int viewIdx = report->getCurrentIndex();
int printCopies = numCopies_;
painter.begin(posprinter);
QPaintDeviceMetrics pdm(posprinter);
QSize dim(report->pageDimensions());
painter.setWindow(0, 0, dim.width(), dim.height());
painter.setViewport(0, 0, pdm.width(), pdm.height());
for (int j = 0; j < printCopies; j++) {
report->setCurrentPage(1);
page = report->getCurrentPage();
page->play(&painter);
}
painter.end();
report->setCurrentPage(viewIdx);
delete posprinter;
return true;
}
示例5: signalRenderStatus
/** Renders the report as a page collection - the caller
* is responsible for de-allocating the returned
* collection
*
* copyright : (C) 2002-2008 InfoSiAL S.L.
* email : [email protected]
*
*/
MPageCollection *MReportEngine::renderReport(int initRow, int initCol,
MPageCollection *pages, uint flags)
{
fillRecords_ = flags & MReportEngine::FillRecords;
bool pageBreak = flags & MReportEngine::PageBreak;
bool append = flags & MReportEngine::Append;
cancelRender = false;
currRecord_ = 0;
csvData_ = QString::null;
p->setStyleName(styleName_);
// Create the page collection
QPicture *currentPage = 0;
QPicture *currentPageCopy = 0;
bool lastPageFound = false;
if (pages == 0) {
pages = new MPageCollection(this);
currPage = 0;
} else {
if (append && !pageBreak) {
currX = leftMargin ;
lastPageFound = true;
currentPage = pages->getLastPage();
p->painter()->end();
currentPageCopy = new QPicture(*currentPage);
p->painter()->begin(currentPage);
currentPageCopy->play(p->painter());
delete currentPageCopy;
}
}
// Initialize the basic page data
currHeight = pageHeight - (bottomMargin + pFooter->getHeight());
currDate = QDate::currentDate();
// Initialize the grand total array
clearGrantTotals();
for (int i = 0; i < rFooter->getCalcFieldCount(); i++)
grandTotal->append(new QMemArray<double>);
// Create the first page
if (!lastPageFound)
startPage(pages);
unsigned int rowCount = records.length();
if (rowCount <= 1)
rowCount = 2;
uint nRecord = 0;
// Draw the details
drawDetail(pages, 0, nRecord, initRow, initCol);
// Finish the last page of the report
endPage(pages);
// Destroy the page painter
p->painter()->end();
// Set the page collection attributes
pages->setPageDimensions(QSize(pageWidth, pageHeight));
pages->setPageSize(pageSize);
pages->setPageOrientation(pageOrientation);
pages->setPrintToPos(printToPos);
fillRecords_ = false;
// Send final status
emit signalRenderStatus(rowCount / 2);
return pages;
}
示例6: printReport
//.........这里部分代码省略.........
QMessageBox::critical(this, "Kugar", tr("No hay páginas en el\ninforme para."), QMessageBox::Ok,
QMessageBox::NoButton, QMessageBox::NoButton);
return false;
}
// Set the printer dialog
printer = new QPrinter(QPrinter::HighResolution);
printer->setPageSize((QPrinter::PageSize) report->pageSize());
if ((QPrinter::PageSize) report->pageSize() == QPrinter::Custom)
printer->setCustomPaperSize(report->pageDimensions());
printer->setOrientation((QPrinter::Orientation) report->pageOrientation());
printer->setMinMax(1, cnt);
printer->setFromTo(1, cnt);
printer->setFullPage(true);
printer->setColorMode((QPrinter::ColorMode) colorMode_);
printer->setNumCopies(numCopies_);
printer->setResolution(dpi_);
if (!printerName_.isEmpty())
printer->setPrinterName(printerName_);
QString printProg(aqApp->printProgram());
if (!printProg.isEmpty())
printer->setPrintProgram(aqApp->printProgram());
bool printNow = true;
if (!printerName_.isNull())
printNow = true;
else
printNow = printer->setup(qApp->focusWidget());
if (printNow) {
QPicture *page;
QPainter painter;
bool printRev = false;
// Save the viewer's page index
int viewIdx = report->getCurrentIndex();
// Check the order we are printing the pages
if (printer->pageOrder() == QPrinter::LastPageFirst)
printRev = true;
// Get the count of pages and copies to print
int printFrom = printer->fromPage() - 1;
int printTo = printer->toPage();
int printCnt = (printTo - printFrom);
int printCopies = printer->numCopies();
int totalSteps = printCnt * printCopies;
int currentStep = 1;
// Set copies to 1, QPrinter copies does not appear to work ...
printer->setNumCopies(1);
// Setup the progress dialog
QProgressDialog progress(tr("Imprimiendo Informe..."), tr("Cancelar"), totalSteps, this, tr("progreso"), true);
progress.setMinimumDuration(M_PROGRESS_DELAY);
QObject::connect(&progress, SIGNAL(cancelled()), this, SLOT(slotCancelPrinting()));
progress.setProgress(0);
qApp->processEvents();
// Start the printer
painter.begin(printer);
QPaintDeviceMetrics pdm(printer);
QSize dim(report->pageDimensions());
painter.setWindow(0, 0, dim.width(), dim.height());
painter.setViewport(0, 0, pdm.width(), pdm.height());
// Print each copy
for (int j = 0; j < printCopies; j++) {
// Print each page in the collection
for (int i = printFrom; i < printTo; i++, currentStep++) {
if (!printer->aborted()) {
progress.setProgress(currentStep);
qApp->processEvents();
if (printRev)
report->setCurrentPage((printCnt == 1) ? i : (printCnt - 1) - i);
else
report->setCurrentPage(i);
page = report->getCurrentPage();
page->play(&painter);
if ((i - printFrom) < printCnt - 1)
printer->newPage();
} else {
j = printCopies;
break;
}
}
if (j < printCopies - 1)
printer->newPage();
}
// Cleanup printing
painter.end();
report->setCurrentPage(viewIdx);
delete printer;
return true;
}
delete printer;
return false;
}
示例7: printReportToPS
/** Imprime directamente sobre formato PS */
bool MReportViewer::printReportToPS(const QString &outPsFile)
{
// Check for a report
if (report == 0)
return false;
#if defined(Q_OS_WIN32) || defined(Q_OS_MACX)
return printGhostReportToPS(outPsFile);
#endif
// Get the page count
int cnt = report->pageCount();
// Check if there is a report or any pages to print
if (cnt == 0) {
QMessageBox::critical(this, "Kugar", tr("No hay páginas en el\ninforme para."), QMessageBox::Ok,
QMessageBox::NoButton, QMessageBox::NoButton);
return false;
}
// Set the printer dialog
printer = new QPrinter(QPrinter::HighResolution);
printer->setPageSize((QPrinter::PageSize) report->pageSize());
if ((QPrinter::PageSize) report->pageSize() == QPrinter::Custom)
printer->setCustomPaperSize(report->pageDimensions());
printer->setOrientation((QPrinter::Orientation) report->pageOrientation());
printer->setMinMax(1, cnt);
printer->setFromTo(1, cnt);
printer->setFullPage(true);
printer->setColorMode((QPrinter::ColorMode) colorMode_);
printer->setNumCopies(numCopies_);
printer->setOutputToFile(true);
printer->setOutputFileName(outPsFile);
QPicture *page;
QPainter painter;
bool printRev = false;
// Save the viewer's page index
int viewIdx = report->getCurrentIndex();
// Check the order we are printing the pages
if (printer->pageOrder() == QPrinter::LastPageFirst)
printRev = true;
// Get the count of pages and copies to print
int printFrom = printer->fromPage() - 1;
int printTo = printer->toPage();
int printCnt = (printTo - printFrom);
int printCopies = printer->numCopies();
int totalSteps = printCnt * printCopies;
int currentStep = 1;
// Set copies to 1, QPrinter copies does not appear to work ...
printer->setNumCopies(numCopies_);
printer->setResolution(dpi_);
// Setup the progress dialog
QProgressDialog progress(tr("Imprimiendo Informe..."), tr("Cancelar"), totalSteps, this, tr("progreso"), true);
progress.setMinimumDuration(M_PROGRESS_DELAY);
QObject::connect(&progress, SIGNAL(cancelled()), this, SLOT(slotCancelPrinting()));
progress.setProgress(0);
qApp->processEvents();
// Start the printer
painter.begin(printer);
QPaintDeviceMetrics pdm(printer);
QSize dim(report->pageDimensions());
painter.setWindow(0, 0, dim.width(), dim.height());
painter.setViewport(0, 0, pdm.width(), pdm.height());
// Print each page in the collection
for (int j = 0; j < printCopies; j++) {
for (int i = printFrom; i < printTo; i++, currentStep++) {
if (!printer->aborted()) {
progress.setProgress(currentStep);
qApp->processEvents();
if (printRev)
report->setCurrentPage((printCnt == 1) ? i : (printCnt - 1) - i);
else
report->setCurrentPage(i);
page = report->getCurrentPage();
page->play(&painter);
if ((i - printFrom) < printCnt - 1)
printer->newPage();
} else {
j = printCopies;
break;
}
}
if (j < printCopies - 1)
printer->newPage();
}
// Cleanup printing
painter.end();
report->setCurrentPage(viewIdx);
delete printer;
//.........这里部分代码省略.........
示例8: printGhostReportToPS
bool MReportViewer::printGhostReportToPS(const QString &outPsFile)
{
if (report == 0)
return false;
int cnt = report->pageCount();
if (cnt == 0)
return false;
psprinter = new PSPrinter(PSPrinter::HighResolution);
psprinter->setPageSize((PSPrinter::PageSize) report->pageSize());
if ((PSPrinter::PageSize) report->pageSize() == PSPrinter::Custom)
psprinter->setCustomPaperSize(report->pageDimensions());
psprinter->setOrientation((PSPrinter::Orientation) report->pageOrientation());
psprinter->setMinMax(1, cnt);
psprinter->setFromTo(1, cnt);
psprinter->setFullPage(true);
psprinter->setColorMode((PSPrinter::ColorMode) colorMode_);
psprinter->setNumCopies(numCopies_);
psprinter->setResolution(dpi_);
QPicture *page;
QPainter painter;
bool printRev = false;
int viewIdx = report->getCurrentIndex();
if (psprinter->pageOrder() == QPrinter::LastPageFirst)
printRev = true;
int printFrom = psprinter->fromPage() - 1;
int printTo = psprinter->toPage();
int printCnt = (printTo - printFrom);
int printCopies = psprinter->numCopies();
int totalSteps = printCnt * printCopies;
int currentStep = 1;
psprinter->setNumCopies(1);
psprinter->setOutputToFile(true);
psprinter->setOutputFileName(outPsFile);
QProgressDialog progress(tr("Imprimiendo Informe..."), tr("Cancelar"), totalSteps, this, tr("progreso"), true);
progress.setMinimumDuration(M_PROGRESS_DELAY);
QObject::connect(&progress, SIGNAL(cancelled()), this, SLOT(slotCancelPrinting()));
progress.setProgress(0);
qApp->processEvents();
painter.begin(psprinter);
QPaintDeviceMetrics pdm(psprinter);
QSize dim(report->pageDimensions());
painter.setWindow(0, 0, dim.width(), dim.height());
painter.setViewport(0, 0, pdm.width(), pdm.height());
for (int j = 0; j < printCopies; j++) {
for (int i = printFrom; i < printTo; i++, currentStep++) {
if (!psprinter->aborted()) {
progress.setProgress(currentStep);
qApp->processEvents();
if (printRev)
report->setCurrentPage((printCnt == 1) ? i : (printCnt - 1) - i);
else
report->setCurrentPage(i);
page = report->getCurrentPage();
page->play(&painter);
if ((i - printFrom) < printCnt - 1)
psprinter->newPage();
} else {
j = printCopies;
break;
}
}
if (j < printCopies - 1)
psprinter->newPage();
}
painter.end();
report->setCurrentPage(viewIdx);
delete psprinter;
return true;
}