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. In QSS is there a "not" selector?
Forum Updated to NodeBB v4.3 + New Features

In QSS is there a "not" selector?

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 3.3k Views 2 Watching
  • 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.
  • JonBJ Online
    JonBJ Online
    JonB
    wrote on last edited by
    #1

    In my application stylesheet I have:

    QPushButton {
       ...
    }
    

    with a fair number of styles. I have many different classes derived from QPushButton, all of which do want to inherit the styles. Except for one class (of course!)...

    Did I spot somewhere that there is some kind of not selector-qualifier in QSS? Maybe like:

    QPushButton[not ...] {
       ...
    }
    

    I can't use .QPushButton (leading "dot") selector, as I do want loads of other QPushButton-derived classes to inherit, just not one particular class.

    raven-worxR 1 Reply Last reply
    0
    • JonBJ JonB

      In my application stylesheet I have:

      QPushButton {
         ...
      }
      

      with a fair number of styles. I have many different classes derived from QPushButton, all of which do want to inherit the styles. Except for one class (of course!)...

      Did I spot somewhere that there is some kind of not selector-qualifier in QSS? Maybe like:

      QPushButton[not ...] {
         ...
      }
      

      I can't use .QPushButton (leading "dot") selector, as I do want loads of other QPushButton-derived classes to inherit, just not one particular class.

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @JonB said in In QSS is there a "not" selector?:

      with a fair number of styles. I have many different classes derived from QPushButton, all of which do want to inherit the styles

      See the supported selector types.
      Only pseudo states may be negated using the exclamation mark. For the rest you have to trick with smart attribute selectors or derived class selectors, etc.

      Since you derived from QPushButton and only want one derived class to appear differently, add a style definition for your derived class and reset all properties used in the QPushButton-style.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      JonBJ 1 Reply Last reply
      3
      • raven-worxR raven-worx

        @JonB said in In QSS is there a "not" selector?:

        with a fair number of styles. I have many different classes derived from QPushButton, all of which do want to inherit the styles

        See the supported selector types.
        Only pseudo states may be negated using the exclamation mark. For the rest you have to trick with smart attribute selectors or derived class selectors, etc.

        Since you derived from QPushButton and only want one derived class to appear differently, add a style definition for your derived class and reset all properties used in the QPushButton-style.

        JonBJ Online
        JonBJ Online
        JonB
        wrote on last edited by JonB
        #3

        @raven-worx
        Thanks, I had read that link, that's where I could not see a not, yet I thought I had read somewhere else that one existed. But you have said that would only be for pseudo-states, so I don't see that would help.

        add a style definition for your derived class and reset all properties used in the QPushButton-style

        I don't understand what you mean? I want no properties which might have been applied to the generic QPushButton style elsewhere in some style file. Since end-users can (deliberately) edit the styles for QPushButton in the stylesheet files, I have no idea "what to cancel/override" for my SpecialPushButton class, if that is what you mean? That's why I am searching for a syntax which they can be applied to the generic QPushButton style specification to tell it not to apply whatever styles specified to the SpecialPushButton class.

        raven-worxR 1 Reply Last reply
        0
        • JonBJ JonB

          @raven-worx
          Thanks, I had read that link, that's where I could not see a not, yet I thought I had read somewhere else that one existed. But you have said that would only be for pseudo-states, so I don't see that would help.

          add a style definition for your derived class and reset all properties used in the QPushButton-style

          I don't understand what you mean? I want no properties which might have been applied to the generic QPushButton style elsewhere in some style file. Since end-users can (deliberately) edit the styles for QPushButton in the stylesheet files, I have no idea "what to cancel/override" for my SpecialPushButton class, if that is what you mean? That's why I am searching for a syntax which they can be applied to the generic QPushButton style specification to tell it not to apply whatever styles specified to the SpecialPushButton class.

          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          @JonB
          Qt stylesheet follows the CSS2 syntax, where as the not keyword is CSS3 specific.
          Unfortunately there is no comparison for "inequality" in the property selectors defined.

          To come back to your problem, thats the only solution i see:

          QPushButton {
               prop: ....;
          }
          
          SpecialPushButton {
              prop: resettedValue;
          }
          

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          JonBJ 1 Reply Last reply
          0
          • raven-worxR raven-worx

            @JonB
            Qt stylesheet follows the CSS2 syntax, where as the not keyword is CSS3 specific.
            Unfortunately there is no comparison for "inequality" in the property selectors defined.

            To come back to your problem, thats the only solution i see:

            QPushButton {
                 prop: ....;
            }
            
            SpecialPushButton {
                prop: resettedValue;
            }
            
            JonBJ Online
            JonBJ Online
            JonB
            wrote on last edited by
            #5

            @raven-worx
            I see, thanks for clarifying.

            And I think you understand that unfortunately I don't know which props to use (because user could have set any). Nor for that matter would I know what resettedValues to use, as I don't know the original value and QSS doesn't have prop: initial; or prop: inherit; like CSS does.

            I do use the ~= operator elsewhere, like QPushButton[prop ~= "value"], but it doesn't look like there is a !~= operator, which would have done me.

            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