6

I'm trying to style my QDockWidget so that it has a border when docked and when floating.

I tried:

QDockWidget 
{
    border: 5px solid purple;
}

But this only produced a border when floating. When docked, the border just disappeared.

How can I solve this?

Angie Quijano
  • 4,167
  • 3
  • 25
  • 30
John-Luke Laue
  • 3,736
  • 3
  • 32
  • 60

1 Answers1

6

Try

QDockWidget > QWidget {
    border: 5px solid purple;
}

This is the result for the docked state:

enter image description here

This is the result for the undocked state:

enter image description here

Iuliu
  • 4,001
  • 19
  • 31
  • 1
    I figured I was probably going to have to end up using this method. It's not exactly what I want since this is just styling the QWidget inside the QDockWidget and not the QDockWidget itself. Thanks though! – John-Luke Laue Mar 18 '15 at 20:04
  • What does the > do and why does it work ? – Dariusz Aug 14 '22 at 15:26
  • 1
    @Dariusz `qss` uses the `css` syntax and `>` is called `child combinator`. See more on MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/Child_combinator – Iuliu Aug 15 '22 at 12:26