0

I would like to set the QT QDockWidget DockWidgetClosable property using a StyleSheet . However it's is inside 'features' property.

enter image description here

How can I change it using stylesheets?

I tried it without success.

For instance.

QDockWidget{
    qproperty-floating:false; 
    qproperty-windowTitle:omg12;  
}

Sets the parameter "floating" and "windowTitle" to those respective values. but I haven't found a key to set the "DockWidgetClosable" value.

Daniel Santos
  • 14,328
  • 21
  • 91
  • 174
  • You mean [:closable](http://doc.qt.io/qt-5/stylesheet-reference.html#closable-ps) for example? – IAmInPLS May 19 '16 at 15:00
  • no @AlexisP. :closable is a state selector. I would like to Change this parameters. For instance. qproperty-floating:false; qproperty-windowTitle:omg12; set the parameter "floating" and "windowTitle" – Daniel Santos May 19 '16 at 16:12
  • You can't change it with a style sheet. – IAmInPLS May 19 '16 at 17:44

2 Answers2

1

Since QDockWidget is pretty much considered a "class" in the .qss stylesheet - and if you want to modify the DockWidgetClosable property of all QDockWidget - you'll have to change the values of all the QDockWidget classes like so:

.QDockWidget{
    DockWidgetClosable: true;
}
MaksG
  • 30
  • 4
0

Solution

You can change it with a style sheet actually, but not exactly as described above.

The only way I got it working was by directly calling the qproperty-feature and set its value to a string which contains each name of a sub-feature I want to use and separating them by the vertical bar symbol.

For example:

QDockWidget{
   qproperty-features:"DockWidgetClosable | DockWidgetFloatable | DockWidgetVerticalTitleBar";
}

Where did I find this information?

Unfortunately there is no direct information available, but I discovered a little hint when reading the online documentation:

There you can find a table for the enum constants and the corresponding values. One of the table entries caught my eyes:

Constant Value
QDockWidget::AllDockWidgetFeatures DockWidgetClosable|DockWidgetMovable|DockWidgetFloatable

From this entry I concluded that maybe the sub-features of the qproperty-feature can be set by their names and luckily it worked.

cbuchart
  • 10,847
  • 9
  • 53
  • 93
TomS
  • 1