PDA

View Full Version : Add style to current



mstegehu
28th May 2010, 09:56
Hello,

When I want an additional style effect to the current style of a widget all standard style elements are 'discarded'. How can I keep the current style and just add something?

Example:

I want the titleBar of a dockwidget to be green in the background:



myDockWidget->setStyleSheet(QString::fromUtf8("QDockWidget::title { background: yellowgreen;}"));


The result is that I lose my original border and the text is placed on a different place.

How can I prevent the loss of original styles?

Regards,

Marcel

ChrisW67
28th May 2010, 10:34
Have you tried tried appending it to the current styles? Something like:

myDockWidget->setStyleSheet( myDockWidget->styleSheet() + "\n" + QString::fromUtf8("QDockWidget::title { background: yellowgreen;}") );

Reversing this change will require keeping the old value.

mstegehu
28th May 2010, 10:51
Hello,

QString originalStyleSheet (myDockWidget->styleSheet());

results in an empty string.

Regards,

Marcel