title: PyQt changing QPushButton background color without resetting style
body: <p>I want to change a Button's background color and text color without changing/resetting the whole style.</p>
  
  <p>Currently, I'm using this:</p>
  
  <pre><code>dl_btt.setStyleSheet("background-color: green; color: white")
  </code></pre>
  
  <p>But that changes the whole style of the button:</p>
  
  <p><a href="https://i.stack.imgur.com/SRpjX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SRpjX.png" alt="enter image description here"></a></p>
  
  <p>Since the default style looks like this:</p>
  
  <p><a href="https://i.stack.imgur.com/Fecfr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Fecfr.png" alt="enter image description here"></a></p>
  
  <p>I would like to have something like this:</p>
  
  <p><a href="https://i.stack.imgur.com/fDcng.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fDcng.png" alt="enter image description here"></a></p>
  
  <p>So, if I were to change OS, I want it to use default style and only change the background color.</p>
  
  <p>Can I do this without manually replicating the style?</p>
  
  <p><strong>EDIT</strong>:</p>
  
  <p>@Controlix Thank you for pointing me in the right direction. However, I can't seem to be able to change the background color.</p>
  
  <p>I'm only able to change the border and text color using:</p>
  
  <pre><code>dl_btt = DownloadButton(self, "Skini")
  
  #dl_btt.setStyleSheet("background-color: green; color: white")
  #dl_btt.setPalette(QtGui.QPalette(QtCore.Qt.green))
  
  palette = dl_btt.palette()
  
  role = dl_btt.foregroundRole()
  palette.setColor(role, QtGui.QColor('white'))
  
  role = dl_btt.backgroundRole()
  palette.setColor(role, QtGui.QColor('green'))
  
  dl_btt.setAutoFillBackground(True)
  dl_btt.setPalette(palette)
  </code></pre>
  
  <p>Which gives me this result:</p>
  
  <p><a href="https://i.stack.imgur.com/DLOiB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DLOiB.png" alt="enter image description here"></a></p>
  
  <p>Searching gave me same or similar snippets of code that don't do what I expected it to do.</p>
  
  <p><strong>EDIT 2</strong>:</p>
  
  <p>I gave up on this search and used style sheets, rebuilding the styles as I see fit.</p>
  
  <p>I'm still wondering though... Is it possible, in PyQt, to replicate native style while changing only certain part of a widget?</p>
  
  <p><strong>EDIT 3</strong></p>
  
  <p>I tried:</p>
  
  <pre><code>    palette = dl_btt.palette()
      role = dl_btt.foregroundRole()
      palette.setColor(role, QtGui.QColor('white'))
  
      role = dl_btt.buttonRole()
      palette.setColor(role, QtGui.QColor('green'))
  
      dl_btt.setAutoFillBackground(True)
      dl_btt.setPalette(palette)
  </code></pre>
  
  <p>But I got this error:</p>
  
  <pre><code>AttributeError: 'DownloadButton' object has no attribute 'buttonRole'
  </code></pre>
  
  <p>How can I access the button role? How is it called?</p>
  
  <p>Just in case you need it, here is the DownloadButton class:</p>
  
  <pre><code>class DownloadButton(QtGui.QPushButton):
      def __init__(self, master, *args, **kwargs):
          super(DownloadButton, self).__init__(*args, **kwargs)
          self.master = master
  
      def mousePressEvent(self, ev):
          self.master.startDownload()
  </code></pre>