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. How To Style QPushButton Icon?
Forum Updated to NodeBB v4.3 + New Features

How To Style QPushButton Icon?

Scheduled Pinned Locked Moved General and Desktop
qt5.5qpushbuttoniconstylesheetstylepositionpositioning
8 Posts 2 Posters 11.0k Views 2 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.
  • M Offline
    M Offline
    maximo
    wrote on 2 Oct 2015, 17:30 last edited by
    #1

    I see that we can set the icon property on a QPushButton. I can change the size of it. However, how do I reposition it slightly? Can I use a stylesheet to do that?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 2 Oct 2015, 17:35 last edited by
      #2

      Hi
      not sure the if the image-position works with icon but you could try
      http://doc.qt.io/qt-5/stylesheet-reference.html#image-prop

      M 1 Reply Last reply 2 Oct 2015, 17:58
      0
      • M mrjj
        2 Oct 2015, 17:35

        Hi
        not sure the if the image-position works with icon but you could try
        http://doc.qt.io/qt-5/stylesheet-reference.html#image-prop

        M Offline
        M Offline
        maximo
        wrote on 2 Oct 2015, 17:58 last edited by
        #3

        @mrjj Tried that. I can set a background-image to point to my image resource URL, and then use background-position to position it, but it won't let me do anything except position names. It doesn't support pixel sizing like so:

        background-position:4px left;
        
        M 1 Reply Last reply 2 Oct 2015, 18:04
        0
        • M maximo
          2 Oct 2015, 17:58

          @mrjj Tried that. I can set a background-image to point to my image resource URL, and then use background-position to position it, but it won't let me do anything except position names. It doesn't support pixel sizing like so:

          background-position:4px left;
          
          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 2 Oct 2015, 18:04 last edited by
          #4

          @maximo
          Ok, I kinda feared it would not.

          M 1 Reply Last reply 2 Oct 2015, 18:34
          0
          • M mrjj
            2 Oct 2015, 18:04

            @maximo
            Ok, I kinda feared it would not.

            M Offline
            M Offline
            maximo
            wrote on 2 Oct 2015, 18:34 last edited by
            #5

            @mrjj The only fix I could come up with was creating some transparent background space around the icon image itself, and then moving the icon within that space. I then deleted the old resource image and re-imported the new one. Now my icons line up properly with the text on the right.

            M 1 Reply Last reply 2 Oct 2015, 19:13
            0
            • M maximo
              2 Oct 2015, 18:34

              @mrjj The only fix I could come up with was creating some transparent background space around the icon image itself, and then moving the icon within that space. I then deleted the old resource image and re-imported the new one. Now my icons line up properly with the text on the right.

              M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 2 Oct 2015, 19:13 last edited by
              #6

              @maximo
              Well, its an ok work around I guess.

              M 1 Reply Last reply 2 Oct 2015, 19:43
              0
              • M mrjj
                2 Oct 2015, 19:13

                @maximo
                Well, its an ok work around I guess.

                M Offline
                M Offline
                maximo
                wrote on 2 Oct 2015, 19:43 last edited by
                #7

                @mrjj I guess it would be nice if the Qt developers would provide a stylesheet setting in Qt5.6 (coming soon, perhaps) that allows one to position that icon a little better.

                M 1 Reply Last reply 2 Oct 2015, 19:48
                0
                • M maximo
                  2 Oct 2015, 19:43

                  @mrjj I guess it would be nice if the Qt developers would provide a stylesheet setting in Qt5.6 (coming soon, perhaps) that allows one to position that icon a little better.

                  M Offline
                  M Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on 2 Oct 2015, 19:48 last edited by
                  #8

                  @maximo
                  Agree.
                  I wonder if there is something secret I missed in some Doc.

                  1 Reply Last reply
                  0

                  7/8

                  2 Oct 2015, 19:43

                  • Login

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