I don't understand this bit.
What does m_previewImg's devicePixelRatio have to do with anything if we're only now about to create m_previewImg?
It looks more like this needs a fix in m_previewViewer
Qt supports a high DPI mode where the main coordinate system is virtualized and made independent of the display pixel density.
Geometry is now specified in device independent pixels. This includes widget and item geometry, event geometry, desktop, window and screen
geometry, and animation velocities. Rendered output is in device pixels, which corresponds to the display resolution. The ratio between the
device independent and device pixel coordinate systems is the devicePixelRatio.
High resolution versions of pixmaps have a device pixel ratio value larger than 1 (see QImageReader, QPixmap::devicePixelRatio()). Should it
match the value of the underlying QPaintDevice, it is drawn directly onto the device with no additional transformation applied.
This is for example the case when drawing a QPixmap of 64x64 pixels size with a device pixel ratio of 2 onto a high DPI screen which also has
a device pixel ratio of 2. Note that the pixmap is then effectively 32x32 pixels in user space.
We want to draw scanned images without highdpi scaling by Qt, so we set devicePixelRatio for them,
and thus the size of the scanned image is in device pixels. SelectionItem was modified to keep its
geometry also in device pixels to avoid extra changes in ksaneviewer.cpp. For consistency the same
should be done for "hide" items to avoid transforms such as "d->hideLeft->setRect(fromNative(rect, dpr));",
but it requires to create a separate class for them.
You can test the change without HiDPI monitor by setting env var QT_SCALE_FACTOR=2
use pen->setWidth(0) instead;