title: Can I change the pixel ratio (screen) at runtime?
body: <p>Qt does support a pixel ratio (<code>devicePixelRatio</code>) which is different on my various desktops:</p>
  <ol>
  <li>) Desktop w1920 h1080 - <strong>ratio: 1</strong></li>
  <li>) Desktop w3840 h2160 with <code>qputenv(&quot;QT_AUTO_SCREEN_SCALE_FACTOR&quot;, &quot;1&quot;)</code> results in Desktop w1280 h720 hi DPI <strong>ratio: 3</strong></li>
  <li>) Desktop w3840 h2160 - <strong>ratio: 1</strong> without <code>QT_AUTO_SCREEN_SCALE_FACTOR</code></li>
  </ol>
  <p>I wonder if I can manually adjust this ratio for my application, so for instance using &quot;ratio 2&quot; in example 2 from above.</p>
  <p>So is there a way to set this value at runtime?</p>
  <p>Based on <a href="http://doc.qt.io/qt-5/highdpi.html" rel="nofollow noreferrer">http://doc.qt.io/qt-5/highdpi.html</a> I did try something like</p>
  <pre><code>qputenv(&quot;QT_SCALE_FACTOR&quot;, QString::number(scaleFactor).toLocal8Bit());
  </code></pre>
  <p>Actually I did expect setting <code>int scaleFactor = 3</code> would look like number 2 above, but it is not the same. Also 1-4 looks weird.</p>
  <p>The following 3 lines look similar to <code>qputenv(&quot;QT_AUTO_SCREEN_SCALE_FACTOR&quot;, &quot;1&quot;)</code> (based on <a href="https://stackoverflow.com/a/45168724/356726">https://stackoverflow.com/a/45168724/356726</a> )</p>
  <pre><code>QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
  QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
  qputenv(&quot;QT_SCALE_FACTOR&quot;, &quot;1&quot;);
  </code></pre>
  <hr />
  <p>PS: Follow up of</p>
  <ul>
  <li><a href="https://stackoverflow.com/q/35641742/356726">Style sheets / Qt Designer support for high dpi screens?</a></li>
  <li><a href="https://stackoverflow.com/q/48174863/356726">How to interpret QFontMetrics results?</a></li>
  <li><a href="https://stackoverflow.com/q/35877420/356726">Can I set QT_AUTO_SCREEN_SCALE_FACTOR behavior via API?</a></li>
  <li><a href="https://stackoverflow.com/q/35641742/356726">Style sheets / Qt Designer support for high dpi screens?</a></li>
  </ul>