Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. High-DPI scaling in QQuickImageProvider
Forum Updated to NodeBB v4.3 + New Features

High-DPI scaling in QQuickImageProvider

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 1 Posters 420 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kmakes
    wrote on last edited by
    #1

    Hey there,

    I'm encountering some problems working with high DPI scaling on my derived QQuickImageProvider.
    Basically, I have two sets of images, one for devicePixelRatio() == 1, one for devicePixelRatio() == 2. The second set of images has twice the resolution of course.
    My provider is given the right image path depending on the current screen's devicePixelRatio() value.
    On a device with a ratio of 1 everything is ok, however when the ratio is 2 my image has twice the expected size (which would mean dpi scaling is not working ?).
    I've tried using setDevicePixelRatio() but it does not seem to change anything.
    High DPI scaling already works properly in usual cases (ex: QML image source contains "@2x").

    QPixmap ExternalImageQProvider::requestPixmap(const QString& id, QSize* size, const QSize& requestedSize)
      {
        QPixmap empty;
        auto result = loadPixmap(id).value_or(empty);
    
        // Set DPI according to screen resolution (image source is given according to devicePixelRatio())
        const auto dpr = QGuiApplication::primaryScreen()->devicePixelRatio();
        result.setDevicePixelRatio(dpr); // this did not change anything.
        if (size)
          *size = result.size();
        return result;
      }
    
    1 Reply Last reply
    0
    • K Offline
      K Offline
      Kmakes
      wrote on last edited by
      #2

      I found a thread claiming this is a bug fixed in QT6: https://bugreports.qt.io/browse/QTBUG-96203
      The provided fix. https://codereview.qt-project.org/c/qt/qtdeclarative/+/400147/2/src/quick/items/qquickimagebase.cpp

      I'll just scale my picture in the meantime.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved