Results 1 to 4 of 4

Thread: Stylesheet secondary effects

  1. #1
    Join Date
    Nov 2010
    Posts
    22
    Thanks
    8
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Stylesheet secondary effects

    I am maintaining an existing application for which I want to start using a custom stylesheet. My first trial only defines the background color for a single widget (combobox pushbutton).

    QPushButton#evilButton {
    background-color: red;
    }

    Since I am planning to add many more cases like this I set the stylesheet to the main window.

    Now, to my surprise using that simple stylesheet does not only change the color of my button, but also its size and the arrow that marks the combobox option. I have not defined a global QPushButton {...} entry, but my evilButton shape looks clearly different from all the other buttons.

    How can I make the above entry to change just the color?

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

    Default Re: Stylesheet secondary effects

    You can't.
    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.


  3. The following user says thank you to wysota for this useful post:

    frank100 (25th January 2011)

  4. #3
    Join Date
    Nov 2010
    Posts
    22
    Thanks
    8
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Stylesheet secondary effects

    wow! you've just killed all the joy. I did some web programming and I loved the idea of CSS taking away the presentation information from the code.

    Now having QPushButton#evilButton {..} inheriting from a QPushButton different from the one that the rest of the application is using seems strange.

    My plan B was defining on run time my own QPushButton stylesheet and extract the info from a dummy pushbutton. At least that should solve the issue where the autogenerated QPushButton does not match the one from the system :-(

    I hope Qt fixes that issue within a future! Or is there a reason for that?

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

    Default Re: Stylesheet secondary effects

    Quote Originally Posted by frank100 View Post
    wow! you've just killed all the joy.
    Sorry... life sometimes sucks.

    I did some web programming and I loved the idea of CSS taking away the presentation information from the code.
    Web CSS works in a different way that widget CSS. The latter is an artificial QStyle subclass so when you enable stylesheets for a widget, its style changes to the artificial one so all things drawn customly by your "main" style are gone and you're left with a "naked" widget that you need to "dress". Sometimes the bare stylesheet style output is close to the one provided by the real style and sometimes it is not.

    I hope Qt fixes that issue within a future! Or is there a reason for that?
    It's not that easy. Qt4 will definitely not do that. You would have to have some kinds of hooks for stylesheets in all possible style implementations and the API itself. So essentially stylesheets would have to be drawn by the true style (which is impossible for the "system" styles such as Aqua, WindowsXP and similar) which defeats the purpose of stylesheets.
    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.


  6. The following user says thank you to wysota for this useful post:

    frank100 (26th January 2011)

Similar Threads

  1. Button Effects
    By hiro in forum Newbie
    Replies: 3
    Last Post: 4th July 2010, 17:23
  2. Replies: 2
    Last Post: 5th November 2009, 03:02
  3. Using StyleSheet Without Losing 3D Effects
    By metdos in forum Qt Programming
    Replies: 1
    Last Post: 31st August 2009, 10:20
  4. Debuging a secondary thread
    By ^Nisok^ in forum Newbie
    Replies: 5
    Last Post: 29th April 2009, 08:14
  5. Text Effects
    By BigEd in forum Qt Programming
    Replies: 3
    Last Post: 26th January 2009, 08:58

Tags for this Thread

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.