2、通过设置窗体来实现,将背景色设置为全透。
def set_transparency(self, enabled): if enabled: self.setAutoFillBackground(False) else: self.setAttribute(Qt.WA_NoSystemBackground, False) self.setAttribute(Qt.WA_TranslucentBackground, enabled) self.repaint()这个没有什么好说的,不能让背景半透明。
3.窗口及其上面的控件都半透明: class RollBoxObject(QtGui.QDialog): borderWidth = 300 borderHeight = 200 def __init__(self, parent = None): QtGui.QDialog.__init__(self, parent) self.setWindowFlags(QtCore.Qt.FramelessWindowHint|QtCore.Qt.Dialog) self.setWindowOpacity(0.5) #设置背景透明 self.setAutoFillBackground(True) backcolor = QtGui.QPalette() backcolor.setColor(QtGui.QPalette.Background, QtGui.QColor(255, 0, 0)) self.setPalette(backcolor); 我用这个的时间使终没有好的办法让其子控件不透明。。。 以上代码同让式用与Qt转载于:https://www.cnblogs.com/IceAndWind-kiss/articles/3742652.html
相关资源:垃圾分类数据集及代码