In QSS is there a "not" selector?
-
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
notselector-qualifier in QSS? Maybe like:QPushButton[not ...] { ... }I can't use
.QPushButton(leading "dot") selector, as I do want loads of otherQPushButton-derived classes to inherit, just not one particular class. -
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
notselector-qualifier in QSS? Maybe like:QPushButton[not ...] { ... }I can't use
.QPushButton(leading "dot") selector, as I do want loads of otherQPushButton-derived classes to inherit, just not one particular class.@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.
-
@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.
@raven-worx
Thanks, I had read that link, that's where I could not see anot, 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
QPushButtonstyle elsewhere in some style file. Since end-users can (deliberately) edit the styles forQPushButtonin the stylesheet files, I have no idea "what to cancel/override" for mySpecialPushButtonclass, if that is what you mean? That's why I am searching for a syntax which they can be applied to the genericQPushButtonstyle specification to tell it not to apply whatever styles specified to theSpecialPushButtonclass. -
@raven-worx
Thanks, I had read that link, that's where I could not see anot, 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
QPushButtonstyle elsewhere in some style file. Since end-users can (deliberately) edit the styles forQPushButtonin the stylesheet files, I have no idea "what to cancel/override" for mySpecialPushButtonclass, if that is what you mean? That's why I am searching for a syntax which they can be applied to the genericQPushButtonstyle specification to tell it not to apply whatever styles specified to theSpecialPushButtonclass.@JonB
Qt stylesheet follows the CSS2 syntax, where as thenotkeyword 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; } -
@JonB
Qt stylesheet follows the CSS2 syntax, where as thenotkeyword 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; }@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 whatresettedValues to use, as I don't know the original value and QSS doesn't haveprop: initial;orprop: inherit;like CSS does.I do use the
~=operator elsewhere, likeQPushButton[prop ~= "value"], but it doesn't look like there is a!~=operator, which would have done me.