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. Why the icon is so blurry,so much little mosaic
Forum Updated to NodeBB v4.3 + New Features

Why the icon is so blurry,so much little mosaic

Scheduled Pinned Locked Moved Unsolved General and Desktop
13 Posts 4 Posters 1.2k Views 1 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.
  • nicker playerN Offline
    nicker playerN Offline
    nicker player
    wrote on last edited by
    #1

    I tried the icon with the svg,png,jpg and so on.I edited the icon image with the adobe illustrator .But the Pushbutton viewed stilled not very clearly.I dont know why.So what the factor influnces the looks of the qicon image.

    jsulmJ 1 Reply Last reply
    0
    • nicker playerN nicker player

      I tried the icon with the svg,png,jpg and so on.I edited the icon image with the adobe illustrator .But the Pushbutton viewed stilled not very clearly.I dont know why.So what the factor influnces the looks of the qicon image.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @nicker-player This is not enough information to help you.
      What is the size of the icon (width x height)?
      On which platform?
      What Qt version?
      QML or widget?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      nicker playerN 1 Reply Last reply
      0
      • jsulmJ jsulm

        @nicker-player This is not enough information to help you.
        What is the size of the icon (width x height)?
        On which platform?
        What Qt version?
        QML or widget?

        nicker playerN Offline
        nicker playerN Offline
        nicker player
        wrote on last edited by nicker player
        #3

        @jsulm
        the png file size is 350x350 300dpi(also tried 72dpi and the size 45x45 )
        the pushbutton icon size is 38x38
        i used the widget to set the icon for the pushbutton.
        Qt 5.14.1 on the windows os.
        So is the reason of resource files or maybe related to the codes?

        jsulmJ 1 Reply Last reply
        0
        • nicker playerN nicker player

          @jsulm
          the png file size is 350x350 300dpi(also tried 72dpi and the size 45x45 )
          the pushbutton icon size is 38x38
          i used the widget to set the icon for the pushbutton.
          Qt 5.14.1 on the windows os.
          So is the reason of resource files or maybe related to the codes?

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @nicker-player And the image file looks good if you open it in a image viewer?
          Could be that down-scaling from 350x350 to 38x38 produces a bad result.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          nicker playerN 1 Reply Last reply
          0
          • jsulmJ jsulm

            @nicker-player And the image file looks good if you open it in a image viewer?
            Could be that down-scaling from 350x350 to 38x38 produces a bad result.

            nicker playerN Offline
            nicker playerN Offline
            nicker player
            wrote on last edited by
            #5

            @jsulm
            yeah the viewer looks fine,and I also tried the fixed size for the qt icon such as the 38x38.But it still looks ugly.

            jsulmJ 1 Reply Last reply
            0
            • nicker playerN nicker player

              @jsulm
              yeah the viewer looks fine,and I also tried the fixed size for the qt icon such as the 38x38.But it still looks ugly.

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @nicker-player Can you try with latest Qt 5.15.x release to see whether it works better?

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              nicker playerN 1 Reply Last reply
              0
              • jsulmJ jsulm

                @nicker-player Can you try with latest Qt 5.15.x release to see whether it works better?

                nicker playerN Offline
                nicker playerN Offline
                nicker player
                wrote on last edited by
                #7

                @jsulm
                I think its not the version of the qt,cause I used some icons of svg,it looks well.I just want to figure out what the factor influnces the out looks of the button image.Could you tested the image for me? logo_nav.png

                jsulmJ 1 Reply Last reply
                0
                • nicker playerN nicker player

                  @jsulm
                  I think its not the version of the qt,cause I used some icons of svg,it looks well.I just want to figure out what the factor influnces the out looks of the button image.Could you tested the image for me? logo_nav.png

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @nicker-player Looks good to me on Linux. I set it in designer. How do you set the icon?

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  nicker playerN 1 Reply Last reply
                  0
                  • jsulmJ jsulm

                    @nicker-player Looks good to me on Linux. I set it in designer. How do you set the icon?

                    nicker playerN Offline
                    nicker playerN Offline
                    nicker player
                    wrote on last edited by nicker player
                    #9

                    @jsulm
                    QPixmap pixmap;
                    QSvgRenderer svgRender;
                    svgRender.load(strText);
                    float w = svgRender.defaultSize().width();
                    float h = svgRender.defaultSize().height();
                    pixmap = QPixmap(w,h);
                    pixmap.fill(Qt::transparent);//
                    pixmap.scaled(w,h,Qt::KeepAspectRatio, Qt::SmoothTransformation);
                    QPainter p(&pixmap);
                    p.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing| QPainter::SmoothPixmapTransform);
                    svgRender.render(&p);
                    ///here set the icon with using qlabel
                    QLabel * Icon = new QLabel(this);
                    Icon->setPixmap(pixmap);
                    Icon->setFixedSize(38, 38);

                    jsulmJ 1 Reply Last reply
                    0
                    • nicker playerN nicker player

                      @jsulm
                      QPixmap pixmap;
                      QSvgRenderer svgRender;
                      svgRender.load(strText);
                      float w = svgRender.defaultSize().width();
                      float h = svgRender.defaultSize().height();
                      pixmap = QPixmap(w,h);
                      pixmap.fill(Qt::transparent);//
                      pixmap.scaled(w,h,Qt::KeepAspectRatio, Qt::SmoothTransformation);
                      QPainter p(&pixmap);
                      p.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing| QPainter::SmoothPixmapTransform);
                      svgRender.render(&p);
                      ///here set the icon with using qlabel
                      QLabel * Icon = new QLabel(this);
                      Icon->setPixmap(pixmap);
                      Icon->setFixedSize(38, 38);

                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      @nicker-player I'm confused now: you want to set a PNG file as icon but posted code to render an SVG into a pixmap. So, what do you want to do?
                      Also, Qt supports SVG already, I would expect that you can set SVG directly in a button, but I did not try.

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      nicker playerN 1 Reply Last reply
                      0
                      • jsulmJ jsulm

                        @nicker-player I'm confused now: you want to set a PNG file as icon but posted code to render an SVG into a pixmap. So, what do you want to do?
                        Also, Qt supports SVG already, I would expect that you can set SVG directly in a button, but I did not try.

                        nicker playerN Offline
                        nicker playerN Offline
                        nicker player
                        wrote on last edited by nicker player
                        #11

                        @jsulm
                        I also tried the png and svg files.but the forum could only support the png file.Refused me to upload the svg file.Infact I tried the png method and svg method.but seemed no difference.And what I used to set the icon for the png file is just setIcon(":/res/log_nav.png").

                        And it confused me that I use the other pc,it looks well.So the computer screen high dpi could influnce the looks ?

                        S 1 Reply Last reply
                        0
                        • nicker playerN nicker player

                          @jsulm
                          I also tried the png and svg files.but the forum could only support the png file.Refused me to upload the svg file.Infact I tried the png method and svg method.but seemed no difference.And what I used to set the icon for the png file is just setIcon(":/res/log_nav.png").

                          And it confused me that I use the other pc,it looks well.So the computer screen high dpi could influnce the looks ?

                          S Offline
                          S Offline
                          SimonSchroeder
                          wrote on last edited by
                          #12

                          @nicker-player said in Why the icon is so blurry,so much little mosaic:

                          So the computer screen high dpi could influnce the looks ?

                          Yes, it does. Use QPixmap::setDevicePixelRatio() to set the scaling from your HiDPI display (e.g. if it is set to 150% on Windows, use 1.5 as a factor here).

                          Christian EhrlicherC 1 Reply Last reply
                          0
                          • S SimonSchroeder

                            @nicker-player said in Why the icon is so blurry,so much little mosaic:

                            So the computer screen high dpi could influnce the looks ?

                            Yes, it does. Use QPixmap::setDevicePixelRatio() to set the scaling from your HiDPI display (e.g. if it is set to 150% on Windows, use 1.5 as a factor here).

                            Christian EhrlicherC Offline
                            Christian EhrlicherC Offline
                            Christian Ehrlicher
                            Lifetime Qt Champion
                            wrote on last edited by
                            #13

                            You should update to 6.7 to get proper High-DPI support. Qt5 had a lot of issues with that.

                            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                            Visit the Qt Academy at https://academy.qt.io/catalog

                            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