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 QTreeWidgetItem's icon is so large?
Forum Updated to NodeBB v4.3 + New Features

Why the QTreeWidgetItem's icon is so large?

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 4 Posters 2.1k 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.
  • LimerL Offline
    LimerL Offline
    Limer
    wrote on last edited by Limer
    #1

    0_1542508309796_20181118_103129.png

    The two pictures are both 16x16 pixels.

    I use them by the below codes:

    QTreeWidget::branch:has-children:!has-siblings:closed,
    QTreeWidget::branch:closed:has-children:has-siblings
    {
        border-image: none;
        image: url(:/images/branch_close.png);
    }
    
    QTreeWidget::branch:open:has-children:!has-siblings,
    QTreeWidget::branch:open:has-children:has-siblings
    {
        border-image: none;
        image: url(:/images/branch_open.png);
    }
    

    But as the pic shows, the icon is too large, so I add code treeWidget->setIconSize(QSize(4, 4)); , but it doesn't work.

    We can take a look at the Vmware Workstation, it's icon' size is very appropriate.

    0_1542508434068_20181118_103059.png

    Can someone give me any advice?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      What size are your images ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      LimerL 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        What size are your images ?

        LimerL Offline
        LimerL Offline
        Limer
        wrote on last edited by
        #3

        @SGaist 16x16 pixels

        https://github.com/Hapoa/Visual-Algorithms/blob/develop/src/resources/branch_close.svg
        https://github.com/Hapoa/Visual-Algorithms/blob/develop/src/resources/branch_open.svg

        mrjjM 1 Reply Last reply
        0
        • LimerL Limer

          @SGaist 16x16 pixels

          https://github.com/Hapoa/Visual-Algorithms/blob/develop/src/resources/branch_close.svg
          https://github.com/Hapoa/Visual-Algorithms/blob/develop/src/resources/branch_open.svg

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Limer
          Hi
          In code , you show that you use PNG files
          Doc says
          "If a svg is specified, the image is scaled to the size of the contents rectangle."
          http://doc.qt.io/qt-5/stylesheet-reference.html
          (search for image*)

          So are they png or svg ?

          LimerL 1 Reply Last reply
          1
          • mrjjM mrjj

            @Limer
            Hi
            In code , you show that you use PNG files
            Doc says
            "If a svg is specified, the image is scaled to the size of the contents rectangle."
            http://doc.qt.io/qt-5/stylesheet-reference.html
            (search for image*)

            So are they png or svg ?

            LimerL Offline
            LimerL Offline
            Limer
            wrote on last edited by Limer
            #5

            @mrjj Actually, i tried both of them.

            png first, but find it too large, so try to use svg again.

            png and svg files are all 16x16 pixels.

            What you mean is I should scale the svg to smaller size (such as 4x4 pixels)?

            What you mean is I should scale the png to smaller size (such as 4x4 pixels)?

            raven-worxR 1 Reply Last reply
            0
            • LimerL Limer

              @mrjj Actually, i tried both of them.

              png first, but find it too large, so try to use svg again.

              png and svg files are all 16x16 pixels.

              What you mean is I should scale the svg to smaller size (such as 4x4 pixels)?

              What you mean is I should scale the png to smaller size (such as 4x4 pixels)?

              raven-worxR Offline
              raven-worxR Offline
              raven-worx
              Moderators
              wrote on last edited by
              #6

              @Limer said in Why the QTreeWidgetItem's icon is so large?:

              png and svg files are all 16x16 pixels.

              svg is a vector format = they actually do not have a size per se (mostly a hint) and can be scaled to any size without quality loss

              --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
              If you have a question please use the forum so others can benefit from the solution in the future

              LimerL 1 Reply Last reply
              1
              • raven-worxR raven-worx

                @Limer said in Why the QTreeWidgetItem's icon is so large?:

                png and svg files are all 16x16 pixels.

                svg is a vector format = they actually do not have a size per se (mostly a hint) and can be scaled to any size without quality loss

                LimerL Offline
                LimerL Offline
                Limer
                wrote on last edited by
                #7

                @raven-worx Yes, you are right.

                1 Reply Last reply
                0
                • mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Hi
                  scaling the SVG won't help as it just scales it up.

                  I added some free space around the actual image ( the view box in inscape)
                  to have them be smaller even the actual image was just the same.

                  Like
                  alt text
                  You can just use the margin setting to get this automatically.

                  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