python - Change text color of QCheckBox in pyqt -
i want change color of text next qcheckbox
. have tried these 2 questions:
how change qcheckbox text label color in qt?
none of solutions seem working me.
p = qtgui.qpalette(self.chkbox[i].palette()) p.setcolor(qpalette.active,qpalette.windowtext, qtcore.qt.red) self.top_grid.addwidget(self.chkbox[i],i+2,0)
edit 1: here minimal working code:
from pyqt4 import qtgui, qtcore import sys def main(): app = qtgui.qapplication(sys.argv) w = qtgui.qwidget() top_grid = qtgui.qgridlayout() chkbox=[] chkbox.append(qtgui.qcheckbox('1')) chkbox[0].setstylesheet("color: red") chkbox[0].settooltip('<b>abc</b>' ) top_grid.addwidget(chkbox[0],0,0) w.setlayout(top_grid) w.show() sys.exit(app.exec_()) if __name__ == '__main__': main()
when this, color of tooltip
changes red, text next checkbox remains black.
edit 2: if add line
app.setstyle('cleanlooks')
it works. default style sgi
, where, reason, text color doesn't change. worked other styles.
you using style sheet:
for chbox in self.chkbox: chbox.setstylesheet("color: red")
Comments
Post a Comment