Qt5, Qt6: fixed setting scale factor on normal monitors without scaling. issue #41330

This commit is contained in:
Željan Rikalo 2025-01-12 18:13:11 +01:00
parent 395b854b3c
commit d50b1f2b9b
2 changed files with 12 additions and 6 deletions

View File

@ -873,12 +873,15 @@ var
QtDc: TQtDeviceContext absolute DC; QtDc: TQtDeviceContext absolute DC;
begin begin
if IsValidDC(DC) and (QtDC.vImage <> nil) and (QtDC.vImage.Handle <> nil) then if IsValidDC(DC) and (QtDC.vImage <> nil) and (QtDC.vImage.Handle <> nil) then
begin
if not SameValue(AScaleFactor, QImage_devicePixelRatio(QtDC.vImage.Handle)) then
begin begin
QPainter_end(QtDC.Widget); QPainter_end(QtDC.Widget);
QImage_setDevicePixelRatio(QtDC.vImage.Handle, AScaleFactor); QImage_setDevicePixelRatio(QtDC.vImage.Handle, AScaleFactor);
QPainter_begin(QtDC.Widget, QtDC.vImage.Handle); QPainter_begin(QtDC.Widget, QtDC.vImage.Handle);
end; end;
end; end;
end;
procedure TQtWidgetSet.SetEventHandlerFlags(AHandler: PEventHandler; procedure TQtWidgetSet.SetEventHandlerFlags(AHandler: PEventHandler;
NewFlags: dword); NewFlags: dword);

View File

@ -892,12 +892,15 @@ var
QtDc: TQtDeviceContext absolute DC; QtDc: TQtDeviceContext absolute DC;
begin begin
if IsValidDC(DC) and (QtDC.vImage <> nil) and (QtDC.vImage.Handle <> nil) then if IsValidDC(DC) and (QtDC.vImage <> nil) and (QtDC.vImage.Handle <> nil) then
begin
if not SameValue(AScaleFactor, QImage_devicePixelRatio(QtDC.vImage.Handle)) then
begin begin
QPainter_end(QtDC.Widget); QPainter_end(QtDC.Widget);
QImage_setDevicePixelRatio(QtDC.vImage.Handle, AScaleFactor); QImage_setDevicePixelRatio(QtDC.vImage.Handle, AScaleFactor);
QPainter_begin(QtDC.Widget, QtDC.vImage.Handle); QPainter_begin(QtDC.Widget, QtDC.vImage.Handle);
end; end;
end; end;
end;
procedure TQtWidgetSet.SetEventHandlerFlags(AHandler: PEventHandler; procedure TQtWidgetSet.SetEventHandlerFlags(AHandler: PEventHandler;
NewFlags: dword); NewFlags: dword);