QPushbutton采用scc风格

时间:2016-12-24 16:48:51

标签: python python-2.7 pyqt pyqt4

这是我要展示的图像,因为没有它我很难解释我想要的东西 enter image description here

这是按钮代码:

self.exitBtn = QtGui.QPushButton(self)
self.exitBtn.setGeometry(505, 395, 80, 80)
self.exitBtn.clicked.connect(self.closeApp)
self.exitBtn.setStyleSheet('background: #000;  color: #FF7E00')
self.exitBtn.setIcon(icon)
self.exitBtn.setIconSize(QtCore.QSize(self.exitBtn.width(), self.exitBtn.height()))

正如你可以看到按钮周围有一些虚线边框,可以删除这个'边框'?我尝试设置样式表'border:0px'但它没有帮助。我想这是焦点的事情吗?

1 个答案:

答案 0 :(得分:1)

快速而肮脏的解决方案是:

import matplotlib.pyplot as plt
import numpy as np

x, y = np.random.random((2, 10))
rgba = np.random.random((10, 4))

fig, ax = plt.subplots()
ax.scatter(x, y, s=200, facecolors=rgba)
plt.show()

PS:

通过继承self.exitBtn.setFocusPolicy(QtCore.Qt.NoFocus) 并重新实现QProxyStyle,可以更清洁地完成此操作。但是,drawPrimitive仅在PyQt5中可用。