QWidget does not draw background color

后端 未结 1 1621
囚心锁ツ
囚心锁ツ 2020-11-28 15:26

I am using PySide 1.2.1 with Python 2.7 and I need a widget to draw a colored background. In Qt Designer I created a simple window consisting of a label, a widget containing

相关标签:
1条回答
  • 2020-11-28 15:51

    Set the WA_StyledBackground attribute on the container widget:

    ui = MainWindow()
    ui.setupUi(mainwindow)
    ui.widget.setAttribute(QtCore.Qt.WA_StyledBackground, True)
    

    (PS: for performance reasons, this attribute isn't set by default for some widget classes - but the documentation doesn't seem to specifiy which ones).

    0 讨论(0)
提交回复
热议问题