Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to exclude a specific qwidget ( QToolTip ) from the stylesheet applied on the parent?

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

Scheduled Pinned Locked Moved Solved General and Desktop
stylesheetqtooltip
5 Posts 2 Posters 2.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SajasKK
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • Hamed.MasafiH Offline
      Hamed.MasafiH Offline
      Hamed.Masafi
      wrote on last edited by
      #2
      setStyleSheet( QString( "font-size: %1px; QToolTip{font-size: 10px}" )
          .arg( fontSize ) );
      

      Remote object sharing (OO RPC)
      http://forum.qt.io/topic/60680/remote-object-sharing-oo-rpc-solved

      Advanced, Powerful and easy to use ORM for Qt5
      https://forum.qt.io/topic/67417/advanced-powerful-and-easy-to-use-orm-for-qt5

      S 1 Reply Last reply
      1
      • S Offline
        S Offline
        SajasKK
        wrote on last edited by SajasKK
        #3

        @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;

        S 1 Reply Last reply
        0
        • Hamed.MasafiH Hamed.Masafi
          setStyleSheet( QString( "font-size: %1px; QToolTip{font-size: 10px}" )
              .arg( fontSize ) );
          
          S Offline
          S Offline
          SajasKK
          wrote on last edited by
          #4
          This post is deleted!
          1 Reply Last reply
          0
          • S SajasKK

            @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;

            S Offline
            S Offline
            SajasKK
            wrote on last edited by
            #5

            @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

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved