Skip to content

Hidpi icon scaling bug on Windows #2305

Open

Description

@gitblit

Details for the issue

What did you expect to see?

Toolbar icons that scale correctly on 4k monitor set to 200% magnification. This seems to be a common issue with Qt-based apps, it is not specific to DB4S.

What did you see instead?

image

Useful extra information

The info below often helps, please fill it out if you're able to. :)

What operating system are you using?

  • Windows: ( version: 10.something )
  • Linux: ( distro: ___ )
  • macOS: ( version: ___ )
  • Other: ___

What is your DB4S version?

  • 3.12.0
  • 3.11.x
  • Other: ___

Did you also

Activity

  1. chrisjlocke commented on Jul 1, 2020

    @chrisjlocke
    Member

    Issue #1836 mentions setting an environment variable. Can you try setting this:
    set QT_AUTO_SCREEN_SCALE_FACTOR=1

    Slap that in a command-prompt, then run DB4S from the same command-line. Here's a screencast...
    The directory you go to to run DB4S will be different though, but the process is the same...
    https://screencast-o-matic.com/watch/cYiV1y5r6j

    Set the variable (copied from above), plop into the DB4S directory, then run the .exe.

  2. gitblit commented on Jul 1, 2020

    @gitblit
    Author

    Perfect! I didn't find that before. It does indeed fix the issue. My main entry point for your app is file associations (double-clicking .db files). Is there anyway to make this a setting? Or maybe I can mod the launch definition for the association. 🤔

  3. chrisjlocke commented on Jul 1, 2020

    @chrisjlocke
    Member

    Yay! Thanks for reporting back! Glad it worked. We'll try and bake this into a nightly to test, as its the second report of it.

    As for double-clicking, we can change the association. Create a batch file, then right-click on a .db file, select 'Properties', then click 'Change', then find the batch file. The batch file would be:

    set QT_AUTO_SCREEN_SCALE_FACTOR=1
    c:
    cd "c:\program files\db4s"
    call "DB Browser for SQLite.exe" %1
    

    So you'd need the %1 to pass in the filename. Think you'll need the 'call' bit, otherwise the command-prompt window hangs around until you close DB4S, which can be annoying. Haven't tested this though...
    Obviously change the directory after the CD command to wherever you have DB4S installed...

  4. justinclift commented on Jul 1, 2020

    @justinclift
    Member

    It could also be set in Windows itself, to apply to everything. It should then apply automatically to all Qt applications

    Whether or not that's a helpful thing is the next question... 😄

  5. gitblit commented on Jul 1, 2020

    @gitblit
    Author

    Great idea @justinclift. I'll give that a go and see if it breaks any of the other QT apps I might have.

  6. chrisjlocke commented on Aug 24, 2020

    @chrisjlocke
    Member

    @gitblit - I assume all was good?

    @justinclift - To close this issue, is this something we'd have to add to the DB4S code, or just something the user would have to run pre-running DB4S? (stick it in a batch file, etc).

  7. gitblit commented on Aug 24, 2020

    @gitblit
    Author

    @chrisjlocke all good! I am using the global environment variable workaround with success!

  8. justinclift commented on Aug 24, 2020

    @justinclift
    Member

    @gitblit Thanks for the confirmation, that's really helpful. People have mentioned scaling issues with DB4S with HiDPI monitors on Windows before, so having a potential solution is a definite win.

    @chrisjlocke Now that it's been confirmed to work, we should probably look at setting that environment variable (or an equivalent Qt setting) at startup time. Not sure if it'll need to be set just for Windows, or if it's safe to set on all platforms, etc.

    @MKleusberg Setting the QT_AUTO_SCREEN_SCALE_FACTOR variable (with a value of 1) at start up on Windows is probably safe, yeah?

  9. chrisjlocke commented on Aug 24, 2020

    @chrisjlocke
    Member

    Setting the variable (with a value of 1) at start up on Windows is probably safe, yeah?

    The only 'gotcha' is that as its an environment variable, it'll affect other Qt programs until Windows is restarted or that variable is changed. If its going to be implemented, I'd suggest a command-line switch so that it could be turned off - so set on by default /unless/ a command-switch of --noAutoScreenScaleFactor (as an example) is present...
    It might only affect one person out of a million but .... well, just thinking out loud....

  10. justinclift commented on Aug 25, 2020

    @justinclift
    Member

    The only 'gotcha' is that as its an environment variable, it'll affect other Qt programs until Windows ...

    I was meaning more "add it to the DB4S environment for this run of the application", rather than "add it to the system wide environment for everyone". 😄

  11. justinclift commented on Sep 10, 2020

    @justinclift
    Member
  12. scottfurry commented on Sep 12, 2020

    @scottfurry
    Contributor

    Piling on to conversation.
    Ref: https://doc.qt.io/qt-5/highdpi.html

    See section "Migrate Existing Applications".

  13. MKleusberg commented on Sep 13, 2020

    @MKleusberg
    Member

    Looking at https://doc.qt.io/qt-5/highdpi.html it says:

    QT_AUTO_SCREEN_SCALE_FACTOR [boolean] enables automatic scaling, based on the monitor's pixel density. This won't change the size of point-sized fonts, since point is a physical measurement unit. Multiple screens may get different scale factors.
    QT_SCALE_FACTOR [numeric] defines a global scale factor for the whole application, including point-sized fonts.

    So it would make sense that setting QT_AUTO_SCREEN_SCALE_FACTOR to 1 would fix most of the UI except for the font sizes. Maybe using the new "Font Size" option in the General tab of DB4S's Preferences dialog can be used to adjust that separately. If that works we could try to figure out a way to calculate a good default value for the Font Size option and set that along with QT_AUTO_SCREEN_SCALE_FACTOR.

  14. user9931 commented on Jul 16, 2022

    @user9931

    QT_AUTO_SCREEN_SCALE_FACTOR=1 works perfectly, but why this is no by default? think its necessary for anyone with hidpi display... also, font size are still need to be changed manually

  15. sky5walk commented on Sep 19, 2022

    @sky5walk

    This is PC dependent. I have 2 laptops but only 1 has the tiny font issue.
    Will this be a DB4S preference setting or hardcoded?
    Adjusting environment variables is not a good solution unless the installer does it.

  16. rob4226 commented on Sep 22, 2022

    @rob4226

    Setting the env variable globally fixed this issue for me also on windows! Well actually, the UI was fixed but the font was still too small but I went to preferences and changed it from 3 to 8 and now it looks perfect on my high dpi screen!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions