Results 1 to 12 of 12

Thread: Using stylesheets without loosing the whole style?

  1. #1
    Join Date
    Feb 2011
    Posts
    16
    Qt products
    Qt5
    Platforms
    Windows

    Default Using stylesheets without loosing the whole 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.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Using stylesheets without loosing the whole 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.

  3. #3
    Join Date
    Feb 2011
    Posts
    16
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Using stylesheets without loosing the whole style?

    Unfortunately it's not always possible. E.g. for Buttons under Vista/Win 7...

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Using stylesheets without loosing the whole style?

    Blame the OS provider.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Feb 2011
    Posts
    16
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Using stylesheets without loosing the whole style?

    Quote Originally Posted by wysota View Post
    Blame the OS provider.
    It's not helpfull...

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Using stylesheets without loosing the whole style?

    Quote Originally Posted by smoon View Post
    It's not helpfull...
    Maybe if enough people write to M$ that they want to be able to change background color of buttons, the vendor will supply a patch allowing one to do this. So far this is simply not possible.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Using stylesheets without loosing the whole style?

    Quote Originally Posted by wysota View Post
    Maybe if enough people write to M$ that they want to be able to change background color of buttons, the vendor will supply a patch allowing one to do this. So far this is simply not possible.
    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.

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Using stylesheets without loosing the whole style?

    Quote Originally Posted by SixDegrees View Post
    Given that it IS possible using stylesheets
    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.

    These are everyday needs that are just that simple in other languages and frameworks, and are needlessly complex (or worse, impossible) in Qt.
    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).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Using stylesheets without loosing the whole style?

    Quote Originally Posted by wysota View Post
    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).
    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.

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Using stylesheets without loosing the whole style?

    Quote Originally Posted by SixDegrees View Post
    That's because originally, Qt did what Java did - it handled it's own drawing instead of relying on variable native GUI elements.
    Qt still does that for all styles but XP/Vista/7/Mac.

    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.
    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. #11
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Using stylesheets without loosing the whole style?

    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."

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Using stylesheets without loosing the whole style?

    Quote Originally Posted by SixDegrees View Post
    Simple settings like chaging the background and foreground, however, are easily accomplished.
    So how do you make a button with a red background and the rest of the style following say... Mac or Windows XP theme?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 3
    Last Post: 21st December 2010, 16:28
  2. How to style QTableView headers using stylesheets?
    By p.csakany in forum Qt Programming
    Replies: 4
    Last Post: 24th October 2010, 22:50
  3. Do Qt Style Sheets support List-style-image?
    By daiheitan in forum Qt Programming
    Replies: 6
    Last Post: 12th March 2010, 02:41
  4. Problems with Gradient style used through Style sheet on ARM platform
    By puneet.narsapur in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 25th January 2010, 13:48
  5. Replies: 1
    Last Post: 7th February 2007, 01:12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.