sajas
sajas

Reputation: 1599

How to exclude a specific widget ( QToolTip ) from the stylesheet applied on the parent

I have a widget class derived from QWidget. Earlier, there was a stylesheet applied on it, to set the font size of all the string in the widget

setStyleSheet( QString( "font-size: %1px;" ).arg( fontSize ) );

This was resulting in all the strings in the widget to have a specific font size. But I would like to have the tooltips in the widget to have the default font style.

Is there a way to achieve this?

I found a similar question in Qt Centre: Setting stylesheet for "almost" all widgets.

Upvotes: 1

Views: 957

Answers (1)

thuga
thuga

Reputation: 12931

You can set the first font size to all widgets with the * selector, and then the second font size to QToolTip objects with type selector:

setStyleSheet("*{font-size: 20px;} QToolTip{ font-size: 8pt; }");

Upvotes: 2

Related Questions