Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.5.2
-
None
-
Kubuntu 22.04 on a Thinkpad X1 Carbon 6th gen
Description
The text size in Qt 6 with the scale factor rounding policy set to Floor, Ceil, Round or RoundPreferFloor is different than it is in Qt 5.
Reproducer
Install Qt 5.15.2 and Qt 6.5.2 to $HOME/Qt via online installer, then extract, build and run the attached test case with both Qt 5 and 6 as follows:
unzip app.zip cd app cmake -DCMAKE_PREFIX_PATH="$HOME/Qt/5.15.2/gcc_64/lib/cmake;$HOME/Qt/6.5.2/gcc_64/lib/cmake" . cmake --build . for app in app_qt5 app_qt6; do for policy in Floor Ceil Round RoundPreferFloor PassThrough; do QT_SCREEN_SCALE_FACTORS=1.25 QT_SCALE_FACTOR_ROUNDING_POLICY=$policy ./$app & done; done
Result
Policy | Qt 5.15.2 | Qt 6.5.2 |
---|---|---|
Floor | ![]() |
![]() |
Ceil | ![]() |
![]() |
Round | ![]() |
![]() |
RoundPreferFloor | ![]() |
![]() |
PassThrough | ![]() |
![]() |
As you can see, these policies have no effect on 5.15.2, despite being documented at https://doc.qt.io/qt-5/highdpi.html as having been introduced in Qt 5.14.
This can lead to Qt 6 applications looking out of place in an environment where both Qt 5 and Qt 6 applications are used.
Including the test case verbatim below as well as attached ZIP.
main.cpp
#include <QApplication> #include <QPushButton> int main(int argc, char *argv[]) { QApplication app(argc, argv); QPushButton button("Hello"); button.resize(300, 50); button.setWindowTitle(QString("%1 - %2").arg(qVersion()).arg(QString::fromUtf8(qgetenv("QT_SCALE_FACTOR_ROUNDING_POLICY")))); button.show(); return app.exec(); }
CMakeLists.txt
cmake_minimum_required(VERSION 3.22) project(app) find_package(Qt6 COMPONENTS Widgets) add_executable(app_qt6 main.cpp) target_link_libraries(app_qt6 PRIVATE Qt6::Widgets) find_package(Qt5 COMPONENTS Widgets) add_executable(app_qt5 main.cpp) target_link_libraries(app_qt5 PRIVATE Qt5::Widgets)
EDIT: This happens also if in the Qt 5 version, the Qt::AA_EnableHighDpiScaling attribute is set. I.e. if main.cpp is changed to:
#include <QApplication> #include <QPushButton> int main(int argc, char *argv[]) { #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); #endif QApplication app(argc, argv); QPushButton button("Hello"); button.resize(300, 50); button.setWindowTitle(QString("%1 - %2").arg(qVersion()).arg(QString::fromUtf8(qgetenv("QT_SCALE_FACTOR_ROUNDING_POLICY")))); button.show(); return app.exec(); }