Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. HiDPI and SVG icon resolution
Forum Updated to NodeBB v4.3 + New Features

HiDPI and SVG icon resolution

Scheduled Pinned Locked Moved Solved General and Desktop
svgiconshidpiresolution
24 Posts 4 Posters 11.3k Views 3 Watching
  • 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.
  • C Offline
    C Offline
    cle1109
    wrote on last edited by
    #21

    Also, here's my main.pro file I used to build the app. It doesn't make a difference whether or not I include svg.

    TEMPLATE = app
    TARGET = main
    
    QT = core gui widgets
    
    SOURCES += main.cpp
    
    1 Reply Last reply
    0
    • S Offline
      S Offline
      SimonSchroeder
      wrote on last edited by
      #22

      You'll need to use the trick with the QPixmap and QPainter in C++ as well. In the background Python and C++ use the exact same functionality, so I wouldn't expect any other behavior without the workaround. (I have experienced this exact problem in C++ multiple times.)

      For your main.pro you need to add the svg module also:

      ...
      QT = core gui widgets svg
      ...
      

      This is what I actually meant with my last post.

      1 Reply Last reply
      0
      • C Offline
        C Offline
        cle1109
        wrote on last edited by
        #23

        You'll need to use the trick with the QPixmap and QPainter in C++ as well. In the background Python and C++ use the exact same functionality, so I wouldn't expect any other behavior without the workaround. (I have experienced this exact problem in C++ multiple times.)

        I get exactly the same result as in Python (the icon is just a random pixel pattern).

        Yes, I know what you meant, I tried adding svg but it didn't make any difference. Same for the workaround. So in conclusion, this seems to be a Qt bug on macOS which also affects PyQt5.

        1 Reply Last reply
        0
        • C Offline
          C Offline
          cle1109
          wrote on last edited by
          #24

          Turns out there is a simple solution:

          app.setAttribute(Qt.AA_UseHighDpiPixmaps)
          
          1 Reply Last reply
          6

          • Login

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