Search the Community
Showing results for tags 'css'.
-
Hi guys, I'm having a simple shelf tool in Houdini: from PySide2 import QtCore, QtGui, QtWidgets class PysideTest(QtWidgets.QMainWindow): def __init__(self, parent=None): super(PysideTest, self).__init__(parent) test = QtWidgets.QWidget() self.resize(800, 800) self.setWindowTitle("This is a test") hbox = QtWidgets.QHBoxLayout() edit = QtWidgets.QLineEdit() edit.setObjectName("QLineEditCustom") print edit.styleSheet() hbox.addWidget(edit) test.setLayout(hbox) self.setCentralWidget(test) #self.setBackgroundRole(QtGui.QPalette.ColorRole.Base) self.setBackgroundRole(QtGui.QPalette.Dark) self.setAutoFillBackground(True) self.show() def run(): mainWidget = hou.qt.mainWindow() css = mainWidget.styleSheet() css_filter_str = 'QLineEdit#QLineEditCustom\n{background: rgb(255, 255, 255); color: rgb(255, 0, 255); selection-background-color: red}' css = "\n".join([css, css_filter_str]) mainWidget.setStyleSheet(css) obj = PysideTest(mainWidget) run() When I press on the shelf tool button I get my UI popping up nicely. This only works if I give the class "PysideTest" the parent "mainWidget", otherwise the UI disappears immediately after clicking on the shelf tool. Now because I'm giving it the "hou.qt.mainWindow()" as a parent, the UI inherits the CSS from its parent. In order to override the CSS on the QLineEdit for instance, I can't just simply write edit.setStyleSheet(), this is being ignored. Instead, I apparently have to grab the CSS from the mainWidget (which is a string) and append my own line using the identifier "#QLineEditCustom". This way it's possible for me to adjust the text color (in my case pink) as well as the selection background color (in my case red), however I'm unable to change the background color of the QLineEdit, which is what I actually want to do. > background: rgb(255, 255, 255) does not work > background-color: rgb(255, 255, 255) does not work either What am I missing here guys? I really like the fact that I can just inherit the CSS from Houdini, but it would be great if there was a more straight forward way of customizing it. The other question I have, what if I wanted to change the background color based on the user text input from color A to color B dynamically, how would I approach that? Thanks in advance, Manu