PDA

View Full Version : Disable Windows DPI Awareness only for printing



O_Cow
26th July 2016, 05:01
Hi,

I am working on GUI application under Windows 7 using Qt 5.5. The basic purpose of the application is to visualize and print some data (both, text and simple graphics).

During testing, I realized that the printout (and also the visualization in a simple form using Qt scene and GraphicsView) doesn't look good in case DPI scaling is set to e.g. 150 %. The text seems a lot larger (1.5 times larger), however the graphics remain same in size as working with 100 % DPI scaling.

I set the dpiawareness of my application to 0 (via qt.conf file). By doing that, the printout looks pretty well, independent of DPI scaling setting. However the app itself looks a little blurry (e.g. Open File Dialog, etc. ...).

Is there a way to leave the application's dpiawareness on the default value while ensuring that the printout looks always the same, independent of DPI scaling setting?

anda_skoa
26th July 2016, 10:40
How do you print?

By passing a QPrinter to QGraphicsScene::render()?

Cheers,
_

O_Cow
26th July 2016, 11:48
Yes. Pretty much like this:


QPrinter printer( QPrinterInfo::defaultPrinter() );
QPainter painter( &printer );
m_pScene->render( &painter, ... );

anda_skoa
26th July 2016, 12:16
Hmm.

In Qt 5.6 you could have tried switching to Qt::AA_DisableHighDpiScaling during printing, but I didn't find any indication is something like that is also possible in 5.5 during runtime.

Cheers,
_