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. [SOLVED] QPushButton and Icon -- How To Move Icon More To The Left?

[SOLVED] QPushButton and Icon -- How To Move Icon More To The Left?

Scheduled Pinned Locked Moved General and Desktop
qpushbuttonqpropertystylingicon
2 Posts 1 Posters 13.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.
  • M Offline
    M Offline
    maximo
    wrote on 25 Aug 2015, 04:15 last edited by maximo
    #1

    I'm a noob to Qt/C++. I have a QPushButton and have learned how to use a resource file, and then use the following stylesheet settings to load an icon on that button. Now I want to know how to put some space somehow between the icon and the text? Is there a stylesheet property for that?

    QPushButton {
    color:#ddd;
    border-radius:0;
    border:0;
    background-color:#555;
    text-align:left;
    padding-left:70px;
    qproperty-icon:url(:/images/icons/icon-scan.png);
    qproperty-iconSize: 20px 20px;
    }
    QPushButton:hover {
    background-color:#666;
    }
    QPushButton:pressed {
    background-color:#333;
    }
    
    M 1 Reply Last reply 25 Aug 2015, 07:48
    0
    • M maximo
      25 Aug 2015, 04:15

      I'm a noob to Qt/C++. I have a QPushButton and have learned how to use a resource file, and then use the following stylesheet settings to load an icon on that button. Now I want to know how to put some space somehow between the icon and the text? Is there a stylesheet property for that?

      QPushButton {
      color:#ddd;
      border-radius:0;
      border:0;
      background-color:#555;
      text-align:left;
      padding-left:70px;
      qproperty-icon:url(:/images/icons/icon-scan.png);
      qproperty-iconSize: 20px 20px;
      }
      QPushButton:hover {
      background-color:#666;
      }
      QPushButton:pressed {
      background-color:#333;
      }
      
      M Offline
      M Offline
      maximo
      wrote on 25 Aug 2015, 07:48 last edited by
      #2

      After scouring the web, it appears that the only way to do this is the very complex technique of subclassing the widget. It's easier to just put another button on it, but then I had the problem where I couldn't pass a hover event to the QPushButton underneath it. This lead me to learn the technique on StackOverflow of building an eventFilter.

      1 Reply Last reply
      0

      1/2

      25 Aug 2015, 04:15

      • Login

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