PDA

View Full Version : Q3Canvas Printing Problem on Windows XP, but OK on Solaris



philw
12th June 2008, 23:47
On Windows, Q3Canvas Printing to a PDF file or to an actual printer is not working. Canvas items are printed with reasonable font sizes, but the positions are very broken -- all overlapping in the top-left corner. It looks to be a scaling problem -- the relative positions of text (relative to each other) seem to be correct. On Solaris though, printing is working properly.

SEE IMAGES (http://cadswes2.colorado.edu/~philw/pub/2008/Q3CanvPrtProb/): http://cadswes2.colorado.edu/~philw/pub/2008/Q3CanvPrtProb/


http://cadswes2.colorado.edu/~philw/pub/2008/Q3CanvPrtProb/WindowsXpBad-Detail.gif

Qt4 Version: 4.3.3
Windows Platform: Microsoft Windows XP, Service Pack 2

Simplified code snippet (similar results):



QPrinter printer (QPrinter::HighResolution);
QPrintDialog printDlg (&printer, this);
const int userResp = printDlg.exec();
if (userResp != QDialog::Rejected)
{
QPainter pPainter (&printer);
Q3Canvas* actQCanvas = _activeCanvas->canvas();
QRect actQCanvasRect = actQCanvas->rect();
actQCanvas->drawArea (actQCanvasRect, &pPainter, false);
}

philw
13th June 2008, 19:40
Update: We are having a similar problem with printing Q3Tables. OK on Solaris, Bad graphics on Windows XP.

SEE (http://cadswes2.colorado.edu/~philw/pub/2008/Q3CanvPrtProb/Q3TableToo.html): http://cadswes2.colorado.edu/~philw/pub/2008/Q3CanvPrtProb/Q3TableToo.html

Qt4 Version: 4.3.3
Windows Platform: Microsoft Windows XP, Service Pack 2

http://cadswes2.colorado.edu/~philw/pub/2008/Q3CanvPrtProb/Q3TableToo-WindowsBad-Detail.gif

philw
18th June 2008, 19:37
Trolltech Support was able to reproduce these printing problems with Q3Canvas and Q3Table, apparently in Qt 4.4. See Bug Number 216354 (http://trolltech.com/developer/task-tracker/index_html?method=entry&id=216354) on http://trolltech.com/developer/task-tracker/ .

philw
2nd July 2008, 04:00
As I now understand ... A QPrinter should NEVER be created with QPrinter::HighResolution if it is to be used to print (i.e. "draw" to a QPrinter) any widgets (e.g. Q3Canvas or Q3Table) that are displayed on the screen.

Unfortunately, the deprecated Qt3 QPrinter::PrinterResolution value is interpreted as QPrinter::HighResolution ON WINDOWS. (On Solaris, it is instead interpreted as QPrinter::ScreenResolution -- so use of that deprecated value didn't have any problems).

Part of my confusion was that there is no indication that QPrinter::HighResolution is not to be used for printing widgets (not stated in the documentation). AND the documentation for "ScreenResolution" states that that "should only be used for drafts". [It needs to be used for printing ALL widgets created within the GUI].

An additional source of confusion was that, using the sample code shown for Q3Canvas::drawArea, with the printer configured with "ScreenResolution" the output is just one page, and is generally blank if the canvas size is large, as ours is. But as it turns out, when using our slightly substantial application code designed to create multiple output pages with only the portion of the canvas containing actual objects, printing works -- when the deprecated "PrinterResolution" value is replaced with "ScreenResolution" (needed on Windows; effectively automatic on Solaris).

Ref: http://doc.trolltech.com/4.3/qprinter.html#PrinterMode-enum