Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>Setting up the QPrinter:</strong></p> <p>By default, a <code>QPrinter</code> object is initialized to screen resolution (usually 96 DPI) unless you specify <code>QPrinter::HighResolution</code> in the constructor which will then use the resolution of the printer in use. </p> <p>If you are setting up the <code>QPrinter</code> object using a <code>QPrintDialog</code> then the code should be something like this:</p> <pre><code>QPrinter printer(QPrinter::HighResolution); QPrintDialog dialog(&amp;printer, this); dialog.exec(); std::cout &lt;&lt; printer.resolution() &lt;&lt; std::endl; </code></pre> <p>After this, the program should output the DPI of the selected printer. In my case it prints out 600.</p> <p>If you aren't using the <code>QPrintDialog</code>, you should use the <code>QPrinter</code> constructor as shown above and then call <code>setResolution(DPI)</code> with the known DPI of your printer.</p> <p>This should result in fonts that are rendered correctly.</p> <p><strong>Update:</strong></p> <p>Now that the weekend is here, I finally had time to properly consider this issue :) Although technically correct for setting up a QPrinter, the above solution is not practical for Graphics scenes that include text specified in point sizes. Since all graphic items are specified in pixel coordinates, it only makes sense to specify font sizes in pixels as well to ensure that fonts appear exactly as expected when mixed with other graphic primitives.</p> <p>There is no need to be concerned about the size of the text on different monitors as the graphics items themselves are not resolution independent. The view can specify scale translations to deal with different resolution and DPI monitors.</p> <p>When printing, by default, the QPrinter scales to fit the entire scene to the page. Which makes sense since a 100 x 100 square on a 600 DPI printer is goint to be 1/6th of an inch wide on your paper :)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload