Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qhighdpiscaling.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qhighdpiscaling_p.h"
5#include "qguiapplication.h"
6#include "qscreen.h"
8#include "qplatformwindow.h"
9#include "private/qscreen_p.h"
10#include <private/qguiapplication_p.h>
11
12#include <QtCore/qdebug.h>
13#include <QtCore/qmetaobject.h>
14
15#include <algorithm>
16#include <optional>
17
19
20Q_LOGGING_CATEGORY(lcHighDpi, "qt.highdpi");
21
22#ifndef QT_NO_HIGHDPISCALING
23
24static const char enableHighDpiScalingEnvVar[] = "QT_ENABLE_HIGHDPI_SCALING";
25static const char scaleFactorEnvVar[] = "QT_SCALE_FACTOR";
26static const char screenFactorsEnvVar[] = "QT_SCREEN_SCALE_FACTORS";
27static const char scaleFactorRoundingPolicyEnvVar[] = "QT_SCALE_FACTOR_ROUNDING_POLICY";
28static const char dpiAdjustmentPolicyEnvVar[] = "QT_DPI_ADJUSTMENT_POLICY";
29static const char usePhysicalDpiEnvVar[] = "QT_USE_PHYSICAL_DPI";
30
31static std::optional<QString> qEnvironmentVariableOptionalString(const char *name)
32{
34 return std::nullopt;
35
36 return std::optional(qEnvironmentVariable(name));
37}
38
39static std::optional<QByteArray> qEnvironmentVariableOptionalByteArray(const char *name)
40{
42 return std::nullopt;
43
44 return std::optional(qgetenv(name));
45}
46
47static std::optional<int> qEnvironmentVariableOptionalInt(const char *name)
48{
49 bool ok = false;
51 auto opt = ok ? std::optional(value) : std::nullopt;
52 return opt;
53}
54
55static std::optional<qreal> qEnvironmentVariableOptionalReal(const char *name)
56{
58 return std::nullopt;
59
60 bool ok = false;
62 return ok ? std::optional(value) : std::nullopt;
63}
64
240qreal QHighDpiScaling::m_factor = 1.0;
241bool QHighDpiScaling::m_active = false; //"overall active" - is there any scale factor set.
242bool QHighDpiScaling::m_usePlatformPluginDpi = false; // use scale factor based on platform plugin DPI
243bool QHighDpiScaling::m_platformPluginDpiScalingActive = false; // platform plugin DPI gives a scale factor > 1
244bool QHighDpiScaling::m_globalScalingActive = false; // global scale factor is active
245bool QHighDpiScaling::m_screenFactorSet = false; // QHighDpiScaling::setScreenFactor has been used
246bool QHighDpiScaling::m_usePhysicalDpi = false;
247QVector<QHighDpiScaling::ScreenFactor> QHighDpiScaling::m_screenFactors;
249QHash<QString, qreal> QHighDpiScaling::m_namedScreenScaleFactors; // Per-screen scale factors (screen name -> factor)
250
251qreal QHighDpiScaling::rawScaleFactor(const QPlatformScreen *screen)
252{
253 // Calculate scale factor beased on platform screen DPI values
255 QDpi platformBaseDpi = screen->logicalBaseDpi();
256 if (QHighDpiScaling::m_usePhysicalDpi) {
257 QSize sz = screen->geometry().size();
258 QSizeF psz = screen->physicalSize();
259 qreal platformPhysicalDpi = ((sz.height() / psz.height()) + (sz.width() / psz.width())) * qreal(25.4 * 0.5);
260 factor = qRound(platformPhysicalDpi) / qreal(platformBaseDpi.first);
261 } else {
262 const QDpi platformLogicalDpi = QPlatformScreen::overrideDpi(screen->logicalDpi());
263 factor = qreal(platformLogicalDpi.first) / qreal(platformBaseDpi.first);
264 }
265
266 return factor;
267}
268
269template <class EnumType>
271{
272 const char *name;
273 EnumType value;
274};
275
276template <class EnumType>
277static bool operator==(const EnumLookup<EnumType> &e1, const EnumLookup<EnumType> &e2)
278{
279 return qstricmp(e1.name, e2.name) == 0;
280}
281
282template <class EnumType>
284{
286 for (; i1 < i2; ++i1) {
287 if (!result.isEmpty())
288 result += QByteArrayLiteral(", ");
289 result += i1->name;
290 }
291 return result;
292}
293
295
297{
303};
304
307{
308 auto end = std::end(scaleFactorRoundingPolicyLookup);
309 auto it = std::find(std::begin(scaleFactorRoundingPolicyLookup), end,
312}
313
315
317{
321};
322
325{
326 auto end = std::end(dpiAdjustmentPolicyLookup);
327 auto it = std::find(std::begin(dpiAdjustmentPolicyLookup), end,
330}
331
333{
334 // Apply scale factor rounding policy. Using mathematically correct rounding
335 // may not give the most desirable visual results, especially for
336 // critical fractions like .5. In general, rounding down results in visual
337 // sizes that are smaller than the ideal size, and opposite for rounding up.
338 // Rounding down is then preferable since "small UI" is a more acceptable
339 // high-DPI experience than "large UI".
340
341 Qt::HighDpiScaleFactorRoundingPolicy scaleFactorRoundingPolicy =
343
344 // Apply rounding policy.
345 qreal roundedFactor = rawFactor;
346 switch (scaleFactorRoundingPolicy) {
348 roundedFactor = qRound(rawFactor);
349 break;
351 roundedFactor = qCeil(rawFactor);
352 break;
354 roundedFactor = qFloor(rawFactor);
355 break;
357 // Round up for .75 and higher. This favors "small UI" over "large UI".
358 roundedFactor = rawFactor - qFloor(rawFactor) < 0.75
359 ? qFloor(rawFactor) : qCeil(rawFactor);
360 break;
363 break;
364 }
365
366 // Clamp the minimum factor to 1. Qt does not currently render
367 // correctly with factors less than 1.
368 roundedFactor = qMax(roundedFactor, qreal(1));
369
370 return roundedFactor;
371}
372
373QDpi QHighDpiScaling::effectiveLogicalDpi(const QPlatformScreen *screen, qreal rawFactor, qreal roundedFactor)
374{
375 // Apply DPI adjustment policy, if needed. If enabled this will change the
376 // reported logical DPI to account for the difference between the rounded
377 // scale factor and the actual scale factor. The effect is that text size
378 // will be correct for the screen dpi, but may be (slightly) out of sync
379 // with the rest of the UI. The amount of out-of-synch-ness depends on how
380 // well user code handles a non-standard DPI values, but since the
381 // adjustment is small (typically +/- 48 max) this might be OK.
382
383 // Apply adjustment policy.
384 const QDpi baseDpi = screen->logicalBaseDpi();
385 const qreal dpiAdjustmentFactor = rawFactor / roundedFactor;
386
387 // Return the base DPI for cases where there is no adjustment
388 if (QHighDpiScaling::m_dpiAdjustmentPolicy == DpiAdjustmentPolicy::Disabled)
389 return baseDpi;
390 if (QHighDpiScaling::m_dpiAdjustmentPolicy == DpiAdjustmentPolicy::UpOnly && dpiAdjustmentFactor < 1)
391 return baseDpi;
392
393 return QDpi(baseDpi.first * dpiAdjustmentFactor, baseDpi.second * dpiAdjustmentFactor);
394}
395
396/*
397 Determine and apply global/initial configuration which do not depend on
398 having access to QScreen objects - this function is called before they
399 have been created. Screen-dependent configuration happens later in
400 updateHighDpiScaling().
401*/
403{
404 qCDebug(lcHighDpi) << "Initializing high-DPI scaling";
405
406 // Read environment variables
407 static const char* envDebugStr = "environment variable set:";
408 std::optional<int> envEnableHighDpiScaling = qEnvironmentVariableOptionalInt(enableHighDpiScalingEnvVar);
409 if (envEnableHighDpiScaling.has_value())
410 qCDebug(lcHighDpi) << envDebugStr << enableHighDpiScalingEnvVar << envEnableHighDpiScaling.value();
411
412 std::optional<qreal> envScaleFactor = qEnvironmentVariableOptionalReal(scaleFactorEnvVar);
413 if (envScaleFactor.has_value())
414 qCDebug(lcHighDpi) << envDebugStr << scaleFactorEnvVar << envScaleFactor.value();
415
416 std::optional<QString> envScreenFactors = qEnvironmentVariableOptionalString(screenFactorsEnvVar);
417 if (envScreenFactors.has_value())
418 qCDebug(lcHighDpi) << envDebugStr << screenFactorsEnvVar << envScreenFactors.value();
419
420 std::optional<int> envUsePhysicalDpi = qEnvironmentVariableOptionalInt(usePhysicalDpiEnvVar);
421 if (envUsePhysicalDpi.has_value())
422 qCDebug(lcHighDpi) << envDebugStr << usePhysicalDpiEnvVar << envUsePhysicalDpi.value();
423
424 std::optional<QByteArray> envScaleFactorRoundingPolicy = qEnvironmentVariableOptionalByteArray(scaleFactorRoundingPolicyEnvVar);
425 if (envScaleFactorRoundingPolicy.has_value())
426 qCDebug(lcHighDpi) << envDebugStr << scaleFactorRoundingPolicyEnvVar << envScaleFactorRoundingPolicy.value();
427
428 std::optional<QByteArray> envDpiAdjustmentPolicy = qEnvironmentVariableOptionalByteArray(dpiAdjustmentPolicyEnvVar);
429 if (envDpiAdjustmentPolicy.has_value())
430 qCDebug(lcHighDpi) << envDebugStr << dpiAdjustmentPolicyEnvVar << envDpiAdjustmentPolicy.value();
431
432 // High-dpi scaling is enabled by default; check for global disable.
433 m_usePlatformPluginDpi = envEnableHighDpiScaling.value_or(1) > 0;
434 m_platformPluginDpiScalingActive = false; // see updateHighDpiScaling()
435
436 // Check for glabal scale factor (different from 1)
437 m_factor = envScaleFactor.value_or(qreal(1));
438 m_globalScalingActive = !qFuzzyCompare(m_factor, qreal(1));
439
440 // Store the envScreenFactors string for later use. The string format
441 // supports using screen names, which means that screen DPI cannot
442 // be resolved at this point.
443 QString screenFactorsSpec = envScreenFactors.value_or(QString());
444 m_screenFactors = parseScreenScaleFactorsSpec(QStringView{screenFactorsSpec});
445 m_namedScreenScaleFactors.clear();
446
447 m_usePhysicalDpi = envUsePhysicalDpi.value_or(0) > 0;
448
449 // Resolve HighDpiScaleFactorRoundingPolicy to QGuiApplication::highDpiScaleFactorRoundingPolicy
450 if (envScaleFactorRoundingPolicy.has_value()) {
451 QByteArray policyText = envScaleFactorRoundingPolicy.value();
452 auto policyEnumValue = lookupScaleFactorRoundingPolicy(policyText);
453 if (policyEnumValue != Qt::HighDpiScaleFactorRoundingPolicy::Unset) {
455 } else {
458 qWarning("Unknown scale factor rounding policy: %s. Supported values are: %s.",
459 policyText.constData(), values.constData());
460 }
461 }
462
463 // Resolve DpiAdjustmentPolicy to m_dpiAdjustmentPolicy
464 if (envDpiAdjustmentPolicy.has_value()) {
465 QByteArray policyText = envDpiAdjustmentPolicy.value();
466 auto policyEnumValue = lookupDpiAdjustmentPolicy(policyText);
467 if (policyEnumValue != DpiAdjustmentPolicy::Unset) {
468 QHighDpiScaling::m_dpiAdjustmentPolicy = policyEnumValue;
469 } else {
471 std::end(dpiAdjustmentPolicyLookup));
472 qWarning("Unknown DPI adjustment policy: %s. Supported values are: %s.",
473 policyText.constData(), values.constData());
474 }
475 }
476
477 // Set initial active state
478 m_active = m_globalScalingActive || m_usePlatformPluginDpi;
479
480 qCDebug(lcHighDpi) << "Initialization done, high-DPI scaling is"
481 << (m_active ? "active" : "inactive");
482}
483
484/*
485 Update configuration based on available screens and screen properties.
486 This function may be called whenever the screen configuration changed.
487*/
489{
490 qCDebug(lcHighDpi) << "Updating high-DPI scaling";
491
492 // Apply screen factors from environment
493 if (m_screenFactors.size() > 0) {
494 qCDebug(lcHighDpi) << "Applying screen factors" << m_screenFactors;
495 int i = -1;
496 const auto screens = QGuiApplication::screens();
497 for (const auto &[name, rawFactor]: m_screenFactors) {
498 const qreal factor = roundScaleFactor(rawFactor);
499 ++i;
500 if (name.isNull()) {
501 if (i < screens.size())
502 setScreenFactor(screens.at(i), factor);
503 } else {
504 for (QScreen *screen : screens) {
505 if (screen->name() == name) {
507 break;
508 }
509 }
510 }
511 }
512 }
513
514 // Check if any screens (now) has a scale factor != 1 and set
515 // m_platformPluginDpiScalingActive if so.
516 if (m_usePlatformPluginDpi && !m_platformPluginDpiScalingActive ) {
517 const auto screens = QGuiApplication::screens();
518 for (QScreen *screen : screens) {
519 if (!qFuzzyCompare(screenSubfactor(screen->handle()), qreal(1))) {
520 m_platformPluginDpiScalingActive = true;
521 break;
522 }
523 }
524 }
525
526 m_active = m_globalScalingActive || m_screenFactorSet || m_platformPluginDpiScalingActive;
527
528 qCDebug(lcHighDpi) << "Update done, high-DPI scaling is"
529 << (m_active ? "active" : "inactive");
530}
531
532/*
533 Sets the global scale factor which is applied to all windows.
534*/
536{
537 qCDebug(lcHighDpi) << "Setting global scale factor to" << factor;
538
539 if (qFuzzyCompare(factor, m_factor))
540 return;
541 if (!QGuiApplication::allWindows().isEmpty())
542 qWarning("QHighDpiScaling::setFactor: Should only be called when no windows exist.");
543
544 const auto screens = QGuiApplication::screens();
545
546 std::vector<QScreenPrivate::UpdateEmitter> updateEmitters;
547 for (QScreen *screen : screens)
548 updateEmitters.emplace_back(screen);
549
550 m_globalScalingActive = !qFuzzyCompare(factor, qreal(1));
551 m_factor = m_globalScalingActive ? factor : qreal(1);
552 m_active = m_globalScalingActive || m_screenFactorSet || m_platformPluginDpiScalingActive ;
553 for (QScreen *screen : screens)
554 screen->d_func()->updateGeometry();
555}
556
557static const char scaleFactorProperty[] = "_q_scaleFactor";
558
559/*
560 Sets a per-screen scale factor.
561*/
563{
564 qCDebug(lcHighDpi) << "Setting screen scale factor for" << screen << "to" << factor;
565
566 if (!qFuzzyCompare(factor, qreal(1))) {
567 m_screenFactorSet = true;
568 m_active = true;
569 }
570
572
573 // Prefer associating the factor with screen name over the object
574 // since the screen object may be deleted on screen disconnects.
575 const QString name = screen->name();
576 if (name.isEmpty())
578 else
579 QHighDpiScaling::m_namedScreenScaleFactors.insert(name, factor);
580
581 screen->d_func()->updateGeometry();
582}
583
585{
586 if (!platformScreen)
587 return pos;
588 const qreal scaleFactor = factor(platformScreen);
589 const QPoint topLeft = platformScreen->geometry().topLeft();
590 return (pos - topLeft) * scaleFactor + topLeft;
591}
592
594{
595 if (!platformScreen)
596 return pos;
597 const qreal scaleFactor = factor(platformScreen);
598 const QPoint topLeft = platformScreen->geometry().topLeft();
599 return (pos - topLeft) / scaleFactor + topLeft;
600}
601
602qreal QHighDpiScaling::screenSubfactor(const QPlatformScreen *screen)
603{
604 auto factor = qreal(1.0);
605 if (!screen)
606 return factor;
607
608 // Unlike the other code where factors are combined by multiplication,
609 // factors from QT_SCREEN_SCALE_FACTORS takes precedence over the factor
610 // computed from platform plugin DPI. The rationale is that the user is
611 // setting the factor to override erroneous DPI values.
612 bool screenPropertyUsed = false;
613 if (m_screenFactorSet) {
614 // Check if there is a factor set on the screen object or associated
615 // with the screen name. These are mutually exclusive, so checking
616 // order is not significant.
617 if (auto qScreen = screen->screen()) {
618 auto screenFactor = qScreen->property(scaleFactorProperty).toReal(&screenPropertyUsed);
619 if (screenPropertyUsed)
620 factor = screenFactor;
621 }
622
623 if (!screenPropertyUsed) {
624 auto byNameIt = QHighDpiScaling::m_namedScreenScaleFactors.constFind(screen->name());
625 if ((screenPropertyUsed = byNameIt != QHighDpiScaling::m_namedScreenScaleFactors.cend()))
626 factor = *byNameIt;
627 }
628 }
629
630 if (!screenPropertyUsed && m_usePlatformPluginDpi)
631 factor = roundScaleFactor(rawScaleFactor(screen));
632
633 return factor;
634}
635
637{
638 // (Note: m_active test is performed at call site.)
639 if (!screen || !screen->handle())
640 return QDpi(96, 96);
641
642 if (!m_usePlatformPluginDpi) {
643 const qreal screenScaleFactor = screenSubfactor(screen->handle());
645 return QDpi{ dpi.first / screenScaleFactor, dpi.second / screenScaleFactor };
646 }
647
648 const qreal scaleFactor = rawScaleFactor(screen->handle());
649 const qreal roundedScaleFactor = roundScaleFactor(scaleFactor);
650 return effectiveLogicalDpi(screen->handle(), scaleFactor, roundedScaleFactor);
651}
652
653// Returns the screen containing \a position, using \a guess as a starting point
654// for the search. \a guess might be nullptr. Returns nullptr if \a position is outside
655// of all screens.
656QScreen *QHighDpiScaling::screenForPosition(QHighDpiScaling::Point position, QScreen *guess)
657{
659 return nullptr;
660
661 auto getPlatformScreenGuess = [](QScreen *maybeScreen) -> QPlatformScreen * {
662 if (maybeScreen)
663 return maybeScreen->handle();
665 return primary->handle();
666 return nullptr;
667 };
668
669 QPlatformScreen *platformGuess = getPlatformScreenGuess(guess);
670 if (!platformGuess)
671 return nullptr;
672
673 auto onScreen = [](QHighDpiScaling::Point position, const QPlatformScreen *platformScreen) -> bool {
674 return position.kind == Point::Native
675 ? platformScreen->geometry().contains(position.point)
676 : platformScreen->screen()->geometry().contains(position.point);
677 };
678
679 // is the guessed screen correct?
680 if (onScreen(position, platformGuess))
681 return platformGuess->screen();
682
683 // search sibling screens
684 const auto screens = platformGuess->virtualSiblings();
685 for (const QPlatformScreen *screen : screens) {
686 if (onScreen(position, screen))
687 return screen->screen();
688 }
689
690 return nullptr;
691}
692
693QVector<QHighDpiScaling::ScreenFactor> QHighDpiScaling::parseScreenScaleFactorsSpec(const QStringView &screenScaleFactors)
694{
696
697 // The spec is _either_
698 // - a semicolon-separated ordered factor list: "1.5;2;3"
699 // - a semicolon-separated name=factor list: "foo=1.5;bar=2;baz=3"
700 const auto specs = screenScaleFactors.split(u';');
701 for (const auto &spec : specs) {
702 const qsizetype equalsPos = spec.lastIndexOf(u'=');
703 if (equalsPos == -1) {
704 // screens in order
705 bool ok;
706 const qreal factor = spec.toDouble(&ok);
707 if (ok && factor > 0) {
708 screenFactors.append(QHighDpiScaling::ScreenFactor(QString(), factor));
709 }
710 } else {
711 // "name=factor"
712 bool ok;
713 const qreal factor = spec.mid(equalsPos + 1).toDouble(&ok);
714 if (ok && factor > 0) {
715 screenFactors.append(QHighDpiScaling::ScreenFactor(spec.left(equalsPos).toString(), factor));
716 }
717 }
718 } // for (specs)
719
720 return screenFactors;
721}
722
724{
726 if (!m_active)
727 return { qreal(1), QPoint() };
728 if (!platformScreen)
729 return { m_factor, QPoint() }; // the global factor
730 return { m_factor * screenSubfactor(platformScreen), platformScreen->geometry().topLeft() };
731}
732
734{
736 if (!m_active)
737 return { qreal(1), QPoint() };
738 if (!screen)
739 return { m_factor, QPoint() }; // the global factor
741}
742
744{
745 if (!m_active)
746 return { qreal(1), QPoint() };
747
748 // Determine correct screen; use the screen which contains the given
749 // position if a valid position is passed.
751 QScreen *overrideScreen = QHighDpiScaling::screenForPosition(position, screen);
752 QScreen *targetScreen = overrideScreen ? overrideScreen : screen;
753 return scaleAndOrigin(targetScreen, position);
754}
755
756#ifndef QT_NO_DEBUG_STREAM
757QDebug operator<<(QDebug debug, const QHighDpiScaling::ScreenFactor &factor)
758{
759 const QDebugStateSaver saver(debug);
760 debug.nospace();
761 if (!factor.name.isEmpty())
762 debug << factor.name << "=";
763 debug << factor.factor;
764 return debug;
765}
766#endif
767
768#else // QT_NO_HIGHDPISCALING
769
771{
772 return { qreal(1), QPoint() };
773}
774
776{
777 return { qreal(1), QPoint() };
778}
779
781{
782 return { qreal(1), QPoint() };
783}
784
785#endif // QT_NO_HIGHDPISCALING
786
788
789#include "moc_qhighdpiscaling_p.cpp"
\inmodule QtCore
Definition qbytearray.h:57
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
Definition qbytearray.h:122
\inmodule QtCore
\inmodule QtCore
static void setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy policy)
static QWindowList allWindows()
Returns a list of all the windows in the application.
QScreen * primaryScreen
the primary (or default) screen of the application.
static QList< QScreen * > screens()
Returns a list of all the screens associated with the windowing system the application is connected t...
static Qt::HighDpiScaleFactorRoundingPolicy highDpiScaleFactorRoundingPolicy()
\inmodule QtCore
Definition qhash.h:818
const_iterator constFind(const Key &key) const noexcept
Definition qhash.h:1279
void clear() noexcept(std::is_nothrow_destructible< Node >::value)
Removes all items from the hash and frees up all memory used by it.
Definition qhash.h:949
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition qhash.h:1283
static qreal roundScaleFactor(qreal rawFactor)
static void setGlobalFactor(qreal factor)
static qreal factor(C *context)
static ScaleAndOrigin scaleAndOrigin(const QPlatformScreen *platformScreen, Point position=Point{ Point::Invalid, QPoint() })
static QPoint mapPositionToNative(const QPoint &pos, const QPlatformScreen *platformScreen)
static QDpi logicalDpi(const QScreen *screen)
static QPoint mapPositionFromNative(const QPoint &pos, const QPlatformScreen *platformScreen)
static void updateHighDpiScaling()
static void initHighDpiScaling()
static void setScreenFactor(QScreen *screen, qreal factor)
Definition qlist.h:74
void append(parameter_type t)
Definition qlist.h:441
bool setProperty(const char *name, const QVariant &value)
Sets the value of the object's name property to value.
The QPlatformScreen class provides an abstraction for visual displays.
static QDpi overrideDpi(const QDpi &in)
virtual QRect geometry() const =0
Reimplement in subclass to return the pixel geometry of the screen.
QScreen * screen() const
virtual QDpi logicalDpi() const
Reimplement this function in subclass to return the logical horizontal and vertical dots per inch met...
virtual QList< QPlatformScreen * > virtualSiblings() const
Returns a list of all the platform screens that are part of the same virtual desktop.
\inmodule QtCore\reentrant
Definition qpoint.h:23
constexpr QPoint topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
Definition qrect.h:220
constexpr QSize size() const noexcept
Returns the size of the rectangle.
Definition qrect.h:241
The QScreen class is used to query screen properties. \inmodule QtGui.
Definition qscreen.h:32
QSizeF physicalSize
the screen's physical size (in millimeters)
Definition qscreen.h:50
QRect geometry
the screen's geometry in pixels
Definition qscreen.h:45
QString name
a user presentable string representing the screen
Definition qscreen.h:36
QPlatformScreen * handle() const
Get the platform screen handle.
Definition qscreen.cpp:83
\inmodule QtCore
Definition qsize.h:207
constexpr qreal width() const noexcept
Returns the width.
Definition qsize.h:321
constexpr qreal height() const noexcept
Returns the height.
Definition qsize.h:324
\inmodule QtCore
Definition qsize.h:25
constexpr int height() const noexcept
Returns the height.
Definition qsize.h:132
constexpr int width() const noexcept
Returns the width.
Definition qsize.h:129
\inmodule QtCore
Definition qstringview.h:76
Q_CORE_EXPORT QList< QStringView > split(QStringView sep, Qt::SplitBehavior behavior=Qt::KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Splits the view into substring views wherever sep occurs, and returns the list of those string views.
Definition qstring.cpp:7987
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
double toDouble(bool *ok=nullptr) const
Returns the string converted to a double value.
Definition qstring.cpp:7642
\inmodule QtCore
Definition qvariant.h:64
\inmodule QtGui
Definition qwindow.h:63
QSet< QString >::iterator it
QStyleOptionButton opt
const PluginKeyMapConstIterator cend
Combined button and popup list for selecting options.
HighDpiScaleFactorRoundingPolicy
#define QByteArrayLiteral(str)
Definition qbytearray.h:52
Q_CORE_EXPORT int qstricmp(const char *, const char *)
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept
Definition qfloat16.h:287
int qRound(qfloat16 d) noexcept
Definition qfloat16.h:281
static const char usePhysicalDpiEnvVar[]
static bool operator==(const EnumLookup< EnumType > &e1, const EnumLookup< EnumType > &e2)
static std::optional< qreal > qEnvironmentVariableOptionalReal(const char *name)
static Qt::HighDpiScaleFactorRoundingPolicy lookupScaleFactorRoundingPolicy(const QByteArray &v)
static const char scaleFactorEnvVar[]
static const char enableHighDpiScalingEnvVar[]
static const DpiAdjustmentPolicyLookup dpiAdjustmentPolicyLookup[]
static const char dpiAdjustmentPolicyEnvVar[]
static const ScaleFactorRoundingPolicyLookup scaleFactorRoundingPolicyLookup[]
static const char scaleFactorRoundingPolicyEnvVar[]
QDebug operator<<(QDebug debug, const QHighDpiScaling::ScreenFactor &factor)
static std::optional< QString > qEnvironmentVariableOptionalString(const char *name)
static std::optional< int > qEnvironmentVariableOptionalInt(const char *name)
static const char screenFactorsEnvVar[]
static std::optional< QByteArray > qEnvironmentVariableOptionalByteArray(const char *name)
static QByteArray joinEnumValues(const EnumLookup< EnumType > *i1, const EnumLookup< EnumType > *i2)
static const char scaleFactorProperty[]
static QHighDpiScaling::DpiAdjustmentPolicy lookupDpiAdjustmentPolicy(const QByteArray &v)
QPair< qreal, qreal > QDpi
#define qWarning
Definition qlogging.h:162
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
int qFloor(T v)
Definition qmath.h:42
int qCeil(T v)
Definition qmath.h:36
constexpr const T & qMax(const T &a, const T &b)
Definition qminmax.h:42
GLenum GLsizei GLsizei GLint * values
[15]
GLsizei const GLfloat * v
[13]
GLuint GLuint end
GLuint name
GLuint64EXT * result
[6]
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
QScreen * screen
[1]
Definition main.cpp:29
QString qEnvironmentVariable(const char *varName, const QString &defaultValue)
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
Q_CORE_EXPORT bool qEnvironmentVariableIsSet(const char *varName) noexcept
Q_CORE_EXPORT int qEnvironmentVariableIntValue(const char *varName, bool *ok=nullptr) noexcept
#define Q_UNUSED(x)
ptrdiff_t qsizetype
Definition qtypes.h:70
double qreal
Definition qtypes.h:92
aWidget window() -> setWindowTitle("New Window Title")
[2]
const char * name
qsizetype lastIndexOf(const AT &t, qsizetype from=-1) const noexcept
Definition qlist.h:962