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. Qt Gradient stylesheet not applying
QtWS25 Last Chance

Qt Gradient stylesheet not applying

Scheduled Pinned Locked Moved General and Desktop
9 Posts 5 Posters 14.6k Views
  • 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.
  • K Offline
    K Offline
    kchandr7
    wrote on 27 Aug 2012, 14:21 last edited by
    #1

    Has anybody used this tool? "Ultimate CSS Gradient Generator":http://www.colorzilla.com/gradient-editor/

    There is a "plug-in":http://userscripts.org/scripts/show/107090 available for firefox, which will enable you to generate a stylehseet in the Qt environment. I have been not succesful at implementing this. Every time I insert the style-sheet in Qt Designer and click apply no changes are applied.

    Qt Designer is good for generating basic gradients, however if this tool works, I'd be really great. I want to know if there is a syntax error.

    Here is one example of a style-sheet being generated by the tool:
    @background: qlineargradient(-45deg, stop: 0 rgba(169,228,247,1), stop: 1 rgba(15,180,231,1));@

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tucnak
      wrote on 28 Aug 2012, 10:36 last edited by
      #2

      Hi, ~kchandr7!

      I think that Qt Designer Gradient Generator Tool cannot have any syntax bugs. So, mostly, you have an error somewhere.

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jys0224
        wrote on 28 Aug 2012, 11:02 last edited by
        #3

        i have not much experience on css for qt,
        but as far as i know, rotated linear gradient is not supported in qss.

        how about removing "-45deg" in css like,
        background: qlineargradient(stop: 0 rgba(169,228,247,1), stop: 1 rgba(15,180,231,1));

        1 Reply Last reply
        0
        • K Offline
          K Offline
          kchandr7
          wrote on 28 Aug 2012, 13:45 last edited by
          #4

          I didnt' mean to say that style sheet was throwing syntax bugs on compiling. What I meant to say that the stylesheet had no effect on the widget.

          Also, I tried the removing the -45deg but still no change :(

          1 Reply Last reply
          0
          • J Offline
            J Offline
            jys0224
            wrote on 28 Aug 2012, 13:57 last edited by
            #5

            ok,, maybe i got it, alpha value was too small,
            with "rgba(15,180,231,1)",,, last "1" is not "1.0", it denotes "1/256" alpha value

            try,
            background: qlineargradient(stop: 0 rgba(169,228,247,255), stop: 1 rgba(15,180,231,255));

            and my bad,, rotated linear gradient is supported by using x1, y1, x2, y2 - syntax.
            like,

            background: qlineargradient(x1:0, y1:0, x2:1, y2:1,
            stop:0 white, stop: 0.4 rgba(10, 20, 30, 40), stop:1 rgb(0, 200, 230, 200))

            good luck.

            1 Reply Last reply
            0
            • K Offline
              K Offline
              kchandr7
              wrote on 28 Aug 2012, 14:03 last edited by
              #6

              Thanks! That worked. That was ignorant of me not seeing the alpha value!

              1 Reply Last reply
              0
              • V Offline
                V Offline
                vezprog
                wrote on 28 Aug 2012, 15:32 last edited by
                #7

                Just a heads up, you might want to tag the style sheet in brackets for the object you are targeting as well so all of the objects within the target object to not inherit the style sheet as well.

                So like this:
                @
                #objectName {
                border: 1px solid black;
                border-radius: 5px;
                background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #9dd53a, stop: .5 #a1d54f, stop: .51 #80c217, stop: 1 #7cbc0a);
                }
                @

                Good luck!

                L 1 Reply Last reply 18 Apr 2021, 14:30
                0
                • K Offline
                  K Offline
                  kchandr7
                  wrote on 28 Aug 2012, 19:47 last edited by
                  #8

                  Thanks, I learned that the hard way. I saw all my other objects in the widget inheriting the style and found it really annoying. I guess I will have to eventually to move all the sytlesheets in the parent widget and include the brackets and the appropriate object name to address them induvidually.

                  1 Reply Last reply
                  0
                  • V vezprog
                    28 Aug 2012, 15:32

                    Just a heads up, you might want to tag the style sheet in brackets for the object you are targeting as well so all of the objects within the target object to not inherit the style sheet as well.

                    So like this:
                    @
                    #objectName {
                    border: 1px solid black;
                    border-radius: 5px;
                    background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #9dd53a, stop: .5 #a1d54f, stop: .51 #80c217, stop: 1 #7cbc0a);
                    }
                    @

                    Good luck!

                    L Offline
                    L Offline
                    Lucas Nardi
                    wrote on 18 Apr 2021, 14:30 last edited by
                    #9

                    Thanks @vezprog, it worked very fine.

                    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