How to exclude a specific qwidget ( QToolTip ) from the stylesheet applied on the parent?
-
I have 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 'qtcentre': http://www.qtcentre.org/threads/12828-Setting-stylesheet-for-quot-almost-quot-all-widgets
-
setStyleSheet( QString( "font-size: %1px; QToolTip{font-size: 10px}" ) .arg( fontSize ) );
-
@Hamed-Masafi
Thanks for the reply.
I tried the following:int fontSize = 100;
int toolTipFontSize = QToolTip::font().pointSize(); //which was 11pt
QString stylesheet = QString( "foint-size: %1px; QToolTip{ font-size: %2pt; }" ).arg( fontSize ).arg( toolTipFontSize );But still all the text are of font-size = 100;
-
This post is deleted!
-
@Hamed-Masafi
Using a *selector to select all other widget and then using the code from your suggestion worked correctly.QString stylesheet = QString( " *{ font-size: %1px; } QToolTip{ font-size: %2pt; }" ).arg( fontSize ).arg( toolTipFontSize );
Thanks