Hi, I’ve got a QGroupBox that is wrapped inside a workspaceControl window and I’m trying to change the color and opacity of it but I’m not sure if it supports that kind of customization.
Does anyone know if there is a way to do that please?
def run():
workspaceControlName = 'MyDockableWindow'
# Delete existing window if it already exists
if cmds.workspaceControl(workspaceControlName, q=True, exists=True):
cmds.deleteUI(workspaceControlName)
# Create the workspace control
workspace_control = cmds.workspaceControl(
workspaceControlName,
label='My Dockable Window',
floating=False,
retain=False
)
# Get the workspace control's underlying QWidget using Maya API
control_widget = omui.MQtUtil.findControl(workspaceControlName)
control_wrap = wrapInstance(int(control_widget), QtWidgets.QWidget)
# Ensure the workspace control background is transparent
control_wrap.setAttribute(QtCore.Qt.WA_TranslucentBackground)
control_wrap.setWindowFlags(control_wrap.windowFlags() | QtCore.Qt.FramelessWindowHint)
# Set the stylesheet with the transparent background and border-radius
control_wrap.setStyleSheet("""
QWidget {
border-radius: 0px;
background-color: rgba(46, 46, 46, 179);
}
""")
# Create an instance of the main widget and add it to the control
main_widget = MainWidget(parent=control_wrap)
# Set a layout if not already set
if not control_wrap.layout():
control_wrap.setLayout(QtWidgets.QVBoxLayout())
# Add the main widget to the workspace control layout
control_wrap.layout().addWidget(main_widget)
print("Main widget shown in workspace control")
if __name__ == "__main__":
run()