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. set QToolButton Icons with qss image

set QToolButton Icons with qss image

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 2 Posters 1.4k Views
  • 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.
  • G Offline
    G Offline
    ggrr
    wrote on 25 Apr 2022, 06:14 last edited by ggrr
    #1

    ee3d4f9e-79ee-402d-9243-15d692c7311c-image.png
    QToolButton{
    image:url(:/icon/delete.png);
    border:none;
    }

    it can show image normaly.
    but when i delete the "border:none" it will not show image

    QToolButton{
    image:url(:/icon/delete.png);
    }

    why?

    C 1 Reply Last reply 25 Apr 2022, 07:24
    0
    • C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 25 Apr 2022, 06:31 last edited by
      #2

      I don't see where you use image-position anywhere in your qss.

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

      G 1 Reply Last reply 25 Apr 2022, 08:37
      0
      • G Offline
        G Offline
        ggrr
        wrote on 25 Apr 2022, 07:21 last edited by
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • G ggrr
          25 Apr 2022, 06:14

          ee3d4f9e-79ee-402d-9243-15d692c7311c-image.png
          QToolButton{
          image:url(:/icon/delete.png);
          border:none;
          }

          it can show image normaly.
          but when i delete the "border:none" it will not show image

          QToolButton{
          image:url(:/icon/delete.png);
          }

          why?

          C Offline
          C Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on 25 Apr 2022, 07:24 last edited by
          #4

          @ggrr said in set QToolButton Icons with qss image:

          but when i delete the "border:none" it will not show image

          More or less described in the documentation:

          "Warning: If you only set a background-color on a QToolButton, the background will not appear unless you set the border property to some value. This is because, by default, the QToolButton draws a native border which completely overlaps the background-color."

          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
          • G Offline
            G Offline
            ggrr
            wrote on 25 Apr 2022, 07:52 last edited by
            #5

            But in real time background-color can work without border property

            C 1 Reply Last reply 25 Apr 2022, 07:54
            0
            • G ggrr
              25 Apr 2022, 07:52

              But in real time background-color can work without border property

              C Offline
              C Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on 25 Apr 2022, 07:54 last edited by
              #6

              @ggrr said in set QToolButton Icons with qss image:

              But in real time

              ?

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

              G 1 Reply Last reply 25 Apr 2022, 08:10
              0
              • C Christian Ehrlicher
                25 Apr 2022, 07:54

                @ggrr said in set QToolButton Icons with qss image:

                But in real time

                ?

                G Offline
                G Offline
                ggrr
                wrote on 25 Apr 2022, 08:10 last edited by
                #7

                @Christian-Ehrlicher sorry my english is not good.
                i mean, i just tried qss like below ,and it worked without "border:" property
                QToolButton{
                background-color:red;
                }

                1 Reply Last reply
                0
                • C Offline
                  C Offline
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote on 25 Apr 2022, 08:20 last edited by
                  #8

                  Then this is maybe (base) style dependent - if the base style allows the override of the color then it works, otherwise it won't.

                  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
                  • C Christian Ehrlicher
                    25 Apr 2022, 06:31

                    I don't see where you use image-position anywhere in your qss.

                    G Offline
                    G Offline
                    ggrr
                    wrote on 25 Apr 2022, 08:37 last edited by
                    #9

                    @Christian-Ehrlicher
                    c4b50969-6e76-4a75-a837-85249c30f485-image.png
                    "This Property" not mean "image:" ??

                    there is a "period" behind "image-position"

                    1 Reply Last reply
                    0
                    • C Offline
                      C Offline
                      Christian Ehrlicher
                      Lifetime Qt Champion
                      wrote on 25 Apr 2022, 08:43 last edited by
                      #10

                      If you think so - then use background-image

                      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

                      2/10

                      25 Apr 2022, 06:31

                      topic:navigator.unread, 8
                      • Login

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