I am trying to set the background of a QDockWidget Title bar based on a custom boolean Q_Property I added to a subclass I created.
I know I can do this by calling "setStyleSheet" programmatically, but I was hoping to do it in the style sheet.
Currently this is what I am doing in my style sheet:
QDockWidget#MyDockWidget[myDockWidgetProperty="true"]::title {
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #AAAAAA, stop: 0.2 #666666, stop: 0.5 #444444, stop: 1.0 #222222);
}
QDockWidget#MyDockWidget[myDockWidgetProperty="true"]::title
{
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #AAAAAA, stop: 0.2 #666666, stop: 0.5 #444444, stop: 1.0 #222222);
}
To copy to clipboard, switch view to plain text mode
But that does not seem to do it. I have also tried
QDockWidget#MyDockWidget::title[myDockWidgetProperty="true"] {
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #AAAAAA, stop: 0.2 #666666, stop: 0.5 #444444, stop: 1.0 #222222);
}
QDockWidget#MyDockWidget::title[myDockWidgetProperty="true"]
{
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #AAAAAA, stop: 0.2 #666666, stop: 0.5 #444444, stop: 1.0 #222222);
}
To copy to clipboard, switch view to plain text mode
But that also failed. In my code I am setting the object name of all my custom dock widgets as "MyDockWidget"
Is there a way to make this work?
Thanks in advance
Added after 31 minutes:
Tried the following also:
QDockWidget#MyDockWidget[myDockWidgetProperty="true"] QDockWidget::title {
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #AAAAAA, stop: 0.2 #666666, stop: 0.5 #444444, stop: 1.0 #222222);
}
QDockWidget#MyDockWidget[myDockWidgetProperty="true"] QDockWidget::title
{
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #AAAAAA, stop: 0.2 #666666, stop: 0.5 #444444, stop: 1.0 #222222);
}
To copy to clipboard, switch view to plain text mode
Hoping that the "QDockWidget::title" would think to look only for a child title and not a child QDockWidget, but that does not seem to have worked either.
Bookmarks