Hi,
is it possible to use stylesheets without loosing the whole style of the element? I find it kind of annoying, if I want to change little things like background or border of a widget that I have to rewrite the complete style.
Hi,
is it possible to use stylesheets without loosing the whole style of the element? I find it kind of annoying, if I want to change little things like background or border of a widget that I have to rewrite the complete style.
No there isn't. But if you only want to change the background or any other single color role, try to use QPalette. It is very simple and most time better then applying a style sheet.
Unfortunately it's not always possible. E.g. for Buttons under Vista/Win 7...
Given that it IS possible using stylesheets, it doesn't seem unreasonable for Qt to provide basic functions that leverage SS infrastructure to offer simple functions like setBackground(), setForeground() and so forth. These are everyday needs that are just that simple in other languages and frameworks, and are needlessly complex (or worse, impossible) in Qt.
Actually it's not. The moment you start using stylesheets, you lose all style decorations. You can even see that in Internet Explorer when browsing a webpage that has a button with a modified color. It will look totally different from a button without a custom background.
It's not about Qt, it's about Windows' style API. Show me one theme-compliant button on Windows XP/Vista/7 with a red background (provided of course the system theme has a different background color by default).These are everyday needs that are just that simple in other languages and frameworks, and are needlessly complex (or worse, impossible) in Qt.
Maybe I wasn't clear. It is entirely possible to control any aspect of button styling you like using stylesheets; the downside is that you have to reinvent the entire style to do so. Given that this is possible, however, it is also entirely possible to provide single-item control over those settings via Qt. In fact, the original versions of Qt did just that, providing simple setBackground(), setForeground(), etc., functions in addition to the more complex palette setting interface that now dominates. That's because originally, Qt did what Java did - it handled it's own drawing instead of relying on variable native GUI elements.
But it would be simple to return to such control through the use of the stylesheet mechanism, hiding the drudgery of complete style definition behind a function call where only a single attribute was modified.
Qt still does that for all styles but XP/Vista/7/Mac.
This fails immediately if the user uses a different theme than the one which is implemented by Qt. You can't possibly emulate complete behaviour of the original theme with stylesheets. For instance you can't do animations whereas the system theme can. There were ideas to introduce animations in QStyle (or somewhere inside it) but then Nokia took over and apparently it wasn't so important anymore.But it would be simple to return to such control through the use of the stylesheet mechanism, hiding the drudgery of complete style definition behind a function call where only a single attribute was modified.
Simple settings like chaging the background and foreground, however, are easily accomplished. We've done that with our own button extension, which has such functions and internally manipulate a stylesheet to get there.
At the end of the day, "Go talk to Microsoft" has far less traction than "Go talk to Nokia."
Bookmarks