p.begin( &printer );
QPaintDeviceMetrics metrics( &printer );
double dpmm = (double)metrics.width() / (double)metrics.widthMM(); //this is dots per mm
double aspect = ( (double)metrics.height() / (double)metrics.heightMM() ) //this is aspect ratio
// Create a ratio which basically shows the size of the printer
// canvas in comparison to the 72dpi postscript canvas.
double ratio = PRINTERDPI/PostscriptDPI;
QPoint margin
= mappings.
marginPoint();
int textEditHeight = 0;
if(myTextEdit) //myTextEdit is the QTextEdit declared as a member variable
textEditHeight = myTextEdit->height() * ratio ;
// print all the pages, looping by column first
bool firstPage = true;
for( int y = minimumPageNumber.y(); y <= maximumPageNumber.y(); ++y )
for( int x = minimumPageNumber.x(); x <= maximumPageNumber.x(); ++x )
{
// do a newPage() before printing the current page
// (except for the first page)
if( firstPage )
{
firstPage = false;
}
else
{
printer.newPage();
}
changePage( x, y );
//check if header is available to be printed
if(myTextEdit)
{
int fontSz = (myTextEdit->fontInfo().pointSize());
fontSz *= printerMap.getScaling(); //printerMap is mappings to printer where I scale
//the font
if( fontSz < 6 )
fontSz = 6;
QFont headerFont
= QFont( myTextEdit
->family
(), fontSz
);
p.setFont( headerFont );
QSimpleRichText richText( myTextEdit->text(),
headerFont,
myTextEdit->context(),
myTextEdit->styleSheet(),
myTextEdit->mimeSourceFactory(),
myTextEdit->height() );
richText.setWidth( &p, myTextEdit->width() );
richText.draw( &p, margin.x(), margin.y(),headerView, colorGroup() );
}
QPainter p;
p.begin( &printer );
QPaintDeviceMetrics metrics( &printer );
double dpmm = (double)metrics.width() / (double)metrics.widthMM(); //this is dots per mm
double aspect = ( (double)metrics.height() / (double)metrics.heightMM() ) //this is aspect ratio
// Create a ratio which basically shows the size of the printer
// canvas in comparison to the 72dpi postscript canvas.
double ratio = PRINTERDPI/PostscriptDPI;
QPoint margin = mappings.marginPoint();
int textEditHeight = 0;
if(myTextEdit) //myTextEdit is the QTextEdit declared as a member variable
textEditHeight = myTextEdit->height() * ratio ;
// print all the pages, looping by column first
bool firstPage = true;
for( int y = minimumPageNumber.y(); y <= maximumPageNumber.y(); ++y )
for( int x = minimumPageNumber.x(); x <= maximumPageNumber.x(); ++x )
{
// do a newPage() before printing the current page
// (except for the first page)
if( firstPage )
{
firstPage = false;
}
else
{
printer.newPage();
}
changePage( x, y );
//check if header is available to be printed
if(myTextEdit)
{
int fontSz = (myTextEdit->fontInfo().pointSize());
fontSz *= printerMap.getScaling(); //printerMap is mappings to printer where I scale
//the font
if( fontSz < 6 )
fontSz = 6;
QFont headerFont = QFont( myTextEdit->family(), fontSz );
p.setFont( headerFont );
QSimpleRichText richText( myTextEdit->text(),
headerFont,
myTextEdit->context(),
myTextEdit->styleSheet(),
myTextEdit->mimeSourceFactory(),
myTextEdit->height() );
richText.setWidth( &p, myTextEdit->width() );
richText.draw( &p, margin.x(), margin.y(),headerView, colorGroup() );
}
To copy to clipboard, switch view to plain text mode
Bookmarks