How To Style QPushButton Icon?
-
wrote on 2 Oct 2015, 17:30 last edited by
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?
-
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 -
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-propwrote on 2 Oct 2015, 17:58 last edited by@mrjj Tried that. I can set a
background-image
to point to my image resource URL, and then usebackground-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;
-
@mrjj Tried that. I can set a
background-image
to point to my image resource URL, and then usebackground-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;
@maximo
Ok, I kinda feared it would not. -
wrote on 2 Oct 2015, 18:34 last edited by
@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.
-
@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.
@maximo
Well, its an ok work around I guess. -
@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.
@maximo
Agree.
I wonder if there is something secret I missed in some Doc.
2/8