Prasad Silva
Prasad Silva

Reputation: 1042

How do you exclude all QToolTips from the Qt global stylesheet selector?

I have a global stylesheet selector (the '*' block) which changes font properties for all Qt widgets in the application. However, that also affects QToolTip - not desired. How do you exclude QToolTip from being affected by the global selector? I couldn't find a stylesheet operator for exclusion.

I can of course not use the global selector and copy the shared styles for every possible widget type. Obviously this is cumbersome, not scalable, clutters the QSS and may not provide full coverage. I'm looking for a better solution.

Upvotes: 0

Views: 863

Answers (2)

philr
philr

Reputation: 21

Add this line:

QToolTip{}

Should reset the QToolTip style to default.

Upvotes: 2

Jablonski
Jablonski

Reputation: 18514

QToolTip uses font from widget. You apply another font to widget so this font applies also to tooltip. To avoid this try to use html tooltip:

ui->lineEdit->setToolTip("<font face =\"aharoni\">test</font>");
ui->lineEdit->setText("test");

Result with aharoni font (for better visual comparison):

enter image description here

with *{font-family:consolas} stylesheet.

Upvotes: 1

Related Questions