ui/clickandgowidget: fix scaling issues on high-DPI screens#1947
Open
jpue wants to merge 1 commit intomcallegari:masterfrom
Open
ui/clickandgowidget: fix scaling issues on high-DPI screens#1947jpue wants to merge 1 commit intomcallegari:masterfrom
jpue wants to merge 1 commit intomcallegari:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe the bug / To Reproduce
> 100%, Ubuntu/Linux:QT_SCALE_FACTOR=1.5 qlcplus …)Tomshine Mini Gobo Moving Head) and switch to theSimple Desk.Expected behaviour
Regardless of the resolution or scaling, all text labels and icons should be drawn sharply, with the possible exception of raster images, which have a low resolution to begin with.
Problem Analysis
With the switch from Qt5 to Qt6, many settings related to a high-dpi resolution were changed from “opt-in” to “enabled by default” or “always enabled”. For example, the
Qt::ApplicationAttributeenum no longer contains the propertiesQt::AA_EnableHighDpiScalingandQt::AA_DisableHighDpiScaling(sources: Qt5, Qt6), which can be used to control the scaling behaviour for the entire application.However, most standard Qt UI elements handle this well by default, details can be found in this documentation page.
On the other hand, custom elements such as
QImageandQPixmapdo not handle this (correctly) by default (see here).In QLC+, those elements are used to render the text labels and images/icons in the
ClickAndGoWidgetclass.Proposed Solution
A practical example of how to solve this issue can be found here.
However, as indicated here, using the global/application-wide
devicePixelRatiomay not be the ideal solution, since users may be using multiple different screens.Furthermore, the academically clean solution would be to create a subclass of
QImageand override thepaintEventmethod with a custom one, which takes DPI-related scaling into account.Since QLC+ is only affected in one place by this, I chose the more practical approach, writing a “factory method” for
QImagethat sets all necessary parameters based on the values of the underlying parentQWidget.The static variant of this method is used by the inner class
ClickAndGoWidget::PresetResourceand helps to centralise the code additions, resulting in minimal changes in existing code.I also took the opportunity to apply the recent “initialisation list”, “final class” and “const methods” refactorings to the
ClickAndGoWidgetclass.