Warn on setHighDpiScaleFactorRoundingPolicy misuse

The rounding policy is used to calculate QScreen geometry
during startup. Changing it afterwards is not supported
since we don't have an update mechanism.

This restriction is already documented but printing
a warning makes sense since this is easy to miss.

Fixes: QTBUG-123102
Change-Id: Ib88511e61abbf97436a13dc5d38d3d1fbd5aab2c
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Morten Sørvig 2024-04-03 11:36:06 +02:00 committed by Morten Johan Sørvig
parent b4090305d0
commit d570293bb8

View File

@ -3797,6 +3797,8 @@ Qt::ApplicationState QGuiApplication::applicationState()
*/
void QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy policy)
{
if (qApp)
qWarning("setHighDpiScaleFactorRoundingPolicy must be called before creating the QGuiApplication instance");
QGuiApplicationPrivate::highDpiScaleFactorRoundingPolicy = policy;
}