[Interest] How to be notified when widget is moved to another screen?

Elvis Stansvik elvstone at gmail.com
Fri Oct 21 09:22:03 CEST 2016


Using

    QApplication::desktop()->screenNumber(widget);

it's possible to get the screen number of the screen where the widget
is mostly visible.

But how can I be notified when this changes for a particular widget?

Must I monitor the widget's moveEvent/resizeEvent/... myself, and
check if the screen number changed since last time? What about changes
to the screen configuration (switching monitors) which causes to
widget to appear on another screen?

The reason I want to be notified is that I'm using another API, VTK,
which has a quite primitive SetDPI for controlling the DPI used during
font rendering, and since I was using Qt anyway, I was thinking of
using Qt for DPI detection (since VTK doesn't have any cross platform
detection) and also for the detection of when the widget changes
screen, to know which screen to query for its DPI.

Thanks in advance,
Elvis



More information about the Interest mailing list