HI,
I am trying, with no luck, to change teh background color of a widget.
The code apparenly should be easy: for example, here given I create a label and try to set the background to RED, but nothing happens.
Basically I am following the method described here:
https://wiki.qt.io/How_to_Change_the_Background_Color_of_QWidgetI tried also with QPalette.Background for
setColor() (this value is anyway considered obsolete in QT doc) but still no change in color.import PySide2, RLPy
from PySide2 import *
from PySide2.shiboken2 import wrapInstance
#-- Make a global variable contain dialog --#
sample_dialog = None
def run_script():
global sample_dialog
sample_dialog = RLPy.RUi.CreateRDialog()
sample_dialog.SetWindowTitle("Sample Dialog")
#-- Create Pyside layout for RDialog --#
pyside_dialog = wrapInstance(int(sample_dialog.GetWindow()), PySide2.QtWidgets.QDialog)
pyside_dialog.setFixedWidth(200)
sample_layout = pyside_dialog.layout()
#-- Create the Label --#
label = PySide2.QtWidgets.QLabel("Test")
#-- Set the widget color --#
pal = PySide2.QtGui.QPalette()
color_red = PySide2.QtGui.QColor('red')
label.setAutoFillBackground(True)
pal.setColor(PySide2.QtGui.QPalette.Window, color_red)
label.setPalette(pal)
#-- Add Label --#
sample_layout.addWidget(label)
sample_dialog.Show()
Any ideas ?
Thanks
Roberto
My PC:
OS: Windows 10 Pro English 64-bit / CPU: Intel i7-9700 3.6GHz / MB: ASUS ROG Strix Z390 RAM: 32GB DDR4 2.6GHz / HD: 2TB+3TB / SSD: 2x512GB Samsung 860 EVO + 1x2TB Samsung
VB: Palit GTX2080 TI GamingPro 11GB / AB: embedded in the MB and VB (audio from the MOTU M4 I/F) / DirectX: 12